我的wordpress网站上有3种不同的电子邮件类型。
注册电子邮件
忘记密码的电子邮件所有其他电子邮件/* Custom user registration email */
function set_bp_message_content_type() {
return \'text/html\';
}
add_filter( \'bp_core_signup_send_validation_email_message\', \'custom_buddypress_activation_message\', 10, 3 );
function custom_buddypress_activation_message( $message, $user_id, $activate_url ) {
add_filter( \'wp_mail_content_type\', \'set_bp_message_content_type\' );
$user = get_userdata( $user_id );
return \'MY HTML MESSAGE HERE\'
}
我创建了另一个功能来修改注册电子邮件,如下所示:
/* Change ccontent type to HTML */
add_action( \'login_form_retrievepassword\', function()
{ add_filter( \'wp_mail_content_type\', function() { return text/html; });
});
/* Change Subject */
add_filter( \'retrieve_password_title\', function() {
return \'Complete-Models Password Reset\';
});
/* Change the message/body of the email */
add_filter( \'retrieve_password_message\', \'rv_new_retrieve_password_message\', 10, 2 );
function rv_new_retrieve_password_message( $message, $key ){
// Bail if username or email is not entered
if ( ! isset( $_POST[\'user_login\'] ) )
return;
// Get user\'s data
if ( strpos( $_POST[\'user_login\'], \'@\' ) ) { # by email
$user_data = get_user_by( \'email\', trim( $_POST[\'user_login\'] ) );
} else {
# by username
$login = trim( $_POST[\'user_login\'] );
$user_data = get_user_by( \'login\', $login );
}
// Store some info about the user
$user_fname = $user_data->user_firstname;
$user_login = $user_data->user_login;
$user_email = $user_data->user_email;
// Assembled the URL for resetting the password
$reset_url = add_query_arg(array(
\'action\' => \'rp\',
\'key\' => $key,
\'login\' => rawurlencode( $user_login )
), wp_login_url() );
return \'HTML MESSAGE HERE\';
}
注册电子邮件工作正常,但忘记密码的电子邮件仍以纯文本发送。有没有办法将特定的电子邮件设置为HTML?