Php HTML激活电子邮件Wordpress

Php HTML激活电子邮件Wordpress,php,email,wordpress,Php,Email,Wordpress,你好 我正在尝试编辑WordPress以HTML格式发送的用户激活邮件的标题 问题1 我使用了以下过滤器,但电子邮件发送了两次。一次来自此函数,另一次来自原始函数 问题2 然后,我在wpmu_注册_用户_通知_电子邮件中添加了一个过滤器,以将消息更改为HTML,但当我发送消息时,激活消息的电子邮件为空(在两封电子邮件中),但标题是正确的 问题1过滤器 add_filter( 'wpmu_signup_user_notification', 'tpb_signup_user_notificatio

你好

我正在尝试编辑WordPress以HTML格式发送的用户激活邮件的标题

问题1

我使用了以下过滤器,但电子邮件发送了两次。一次来自此函数,另一次来自原始函数

问题2

然后,我在wpmu_注册_用户_通知_电子邮件中添加了一个过滤器,以将消息更改为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;
}
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 );
add_filter('wpmu_signup_user_notification','tpb_signup_user_notification',10,4);
函数tpb_signup_user_notification($user,$user_email,$key,$meta=array())
{
//发送带有激活链接的电子邮件。
$admin\u电子邮件地址:hello@example.com';
如果($admin_email=='')
$admin_email='support@'。$_SERVER['SERVER_NAME'];
$from_name=get_site_选项('site_name')='''name Here':esc_html(get_site_选项('site_name'));
$message\u headers=“From:\”{$From\u name}\“\n”。“内容类型:text/html;字符集=\”。获取选项(“blog\u字符集”)。“\”\n”;
...
wp_邮件($user_email、$subject、$message、$message_headers);
返回true;
}
问题2过滤器

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;
}
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 );
功能wpse56797\注册\博客\通知\电子邮件($message、$user、$user\email、$key)
{
$message='..';
}
应用过滤器(“wpmu注册用户通知电子邮件”,“wpse56797注册博客通知电子邮件”,10,4);
在“问题2”下显示的函数可能会返回HTML内容

e、 g

“问题2”下显示的函数可能会返回HTML内容

e、 g

“问题2”下显示的函数可能会返回HTML内容

e、 g

“问题2”下显示的函数可能会返回HTML内容

e、 g


我刚刚在我的网站上遇到了问题1,解决方案是您需要从tpb_signup_user_通知函数返回false而不是true,因为在核心函数wpmu_signup_user_通知中,您有

if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) )
        return false;

因此,当您从函数返回false时,上述条件计算为true,从而退出核心函数

我的站点上出现了问题1,解决方案是您需要从tpb_signup_user_通知函数返回false而不是true,因为在核心函数wpmu_signup_user_通知中

if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) )
        return false;

因此,当您从函数返回false时,上述条件计算为true,从而退出核心函数

我的站点上出现了问题1,解决方案是您需要从tpb_signup_user_通知函数返回false而不是true,因为在核心函数wpmu_signup_user_通知中

if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) )
        return false;

因此,当您从函数返回false时,上述条件计算为true,从而退出核心函数

我的站点上出现了问题1,解决方案是您需要从tpb_signup_user_通知函数返回false而不是true,因为在核心函数wpmu_signup_user_通知中

if ( ! apply_filters( 'wpmu_signup_user_notification', $user, $user_email, $key, $meta ) )
        return false;
因此,当您从函数返回false时,上述条件将计算为true,从而退出核心函数