簡體   English   中英

HTML激活電子郵件Wordpress

[英]HTML Activation Email Wordpress

美好的一天,

我正在嘗試編輯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 );

我剛在網站上遇到問題1,解決方法是您需要從tpb_signup_user_notification函數返回false而不是true,因為在核心函數wpmu_signup_user_notification中,

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

因此,當您從函數返回false時,上述條件的計算結果為true,因此退出了核心函數

在“問題2”下顯示的函數可能應該返回HTML內容。

例如

return $message;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM