【发布时间】:2014-02-10 09:59:37
【问题描述】:
美好的一天,
我正在尝试编辑 WordPress 为 HTML 格式的用户激活邮件发送的标题。
问题 1
我使用了以下过滤器,但电子邮件被发送了两次。一个来自这个函数,另一个来自原始函数。
问题 2
然后我向 wpmu_signup_user_notification_email 添加了一个过滤器以将消息更改为 HTML,但是当我发送消息时,激活消息的电子邮件是空白的(在两封电子邮件中),但标题是正确的。
问题 1 过滤器
add_filter( 'wpmu_signup_user_notification', 'tpb_signup_user_notification', 10, 4 );
function tpb_signup_user_notification( $user, $user_email, $key, $meta = array() )
{
// Send email with activation link.
$admin_email = 'hello@example.com';
if ( $admin_email == '' )
$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
$from_name = get_site_option( 'site_name' ) == '' ? 'Name Here' : esc_html( get_site_option( 'site_name' ) );
$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
...
wp_mail($user_email, $subject, $message, $message_headers);
return true;
}
问题 2 过滤器
function wpse56797_signup_blog_notification_email( $message, $user, $user_email, $key )
{
$message = '<table>....</table>';
}
apply_filter('wpmu_signup_user_notification_email','wpse56797_signup_blog_notification_email', 10, 4 );
【问题讨论】: