如何在worpress中使用自定义电子邮件模板覆盖当前注册电子邮件模板



我们如何禁用wordpress中注册的当前电子邮件模板,并在wordpress中将其替换为新的自定义新电子邮件模板。如果有人知道,请告诉我们。

您可以使用此处定义的wp_new_user_notification_email过滤器。这将允许您覆盖默认发送的电子邮件。

您也可以在这里看到它的实现。

/**
* Custom register email
*/
add_filter( 'wp_new_user_notification_email', 'custom_wp_new_user_notification_email', 10, 3 );
function custom_wp_new_user_notification_email( $wp_new_user_notification_email, $user, $blogname ) {

$user_login = stripslashes( $user->user_login );
$user_email = stripslashes( $user->user_email );
$login_url  = wp_login_url();
$message  = __( 'Hi there,' ) . "/r/n/r/n";
$message .= sprintf( __( "Welcome to %s! Here's how to log in:" ), get_option('blogname') ) . "/r/n/r/n";
$message .= wp_login_url() . "/r/n";
$message .= sprintf( __('Username: %s'), $user_login ) . "/r/n";
$message .= sprintf( __('Email: %s'), $user_email ) . "/r/n";
$message .= __( 'Password: The one you entered in the registration form. (For security reason, we save encripted password)' ) . "/r/n/r/n";
$message .= sprintf( __('If you have any problems, please contact me at %s.'), get_option('admin_email') ) . "/r/n/r/n";
$message .= __( 'bye!' );

$wp_new_user_notification_email['subject'] = sprintf( '[%s] Your credentials.', $blogname );
$wp_new_user_notification_email['headers'] = array('Content-Type: text/html; charset=UTF-8');
$wp_new_user_notification_email['message'] = $message;

return $wp_new_user_notification_email;
}

相关内容

  • 没有找到相关文章

最新更新