WordPress修正新用户注册邮件内容的办法

本文实例讲述了如何修正WordPress新用户注册邮件内容,由于零碎发送的邮件是纯文本类型的,页面不太美观,又没有方法发送自定义的HTML格局的邮件,将修正办法分享给大家供大家参考。详细办法如下:

最简略的方法

办法一、间接手动修正:

修正wordpresswp-includes目录的pluggable.php,中的这段:

$message  = sprintf(__('Username: %s'), $user_login) . "";  
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "";
$message .= wp_login_url() . "";
wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);

例如改为如下代码:
$message .= sprintf(__('欢送退出***网')) . "rn";  
$message .= sprintf(__('Username: %s'), $user_login) . "rn";
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "rn";
$message .= wp_login_url() . "rn";
$message .= sprintf(__('账号需进一步审核才能够登入,请告诉网站治理员')) . "rn";
wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);

办法二:

咱们在以后主题的functions.php中退出从新定义的wp_new_user_notification函数即可,上面是一个示例,能够依据本人的需要进行修正:

if ( !function_exists('wp_new_user_notification') ) :  
/**
* Notify the blog admin of a new user, normally via email.
*
* @since 2.0
*
* @param int $user_id User ID
* @param string $plaintext_pass Optional. The user's plaintext password
*/
function wp_new_user_notification($user_id, $plaintext_pass = '') {
$user = get_userdata( $user_id );
$user_login = stripslashes($user->user_login);
$user_email = stripslashes($user->user_email);
// 获取博客称号
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
// 给治理员发送的邮件内容,这里是HTML格局
$message = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>新用户注册</title></head><body><p align="center"><table cellpadding="0" cellspacing="1" style="border:3px solid #d9e9f1;background:#7fbddd; text-align:left;"><tr><td style="padding:0;"><table cellpadding="30" cellspacing="0" style="border:1px solid #ffffff;background:#f7f7f7;width:500px;"><tr><td style="line-height:2;font-size:12px;">您的网站 <strong>' . $blogname . '</strong> 有新用户注册。
用户名:' . $user_login . '
Email:' . $user_email . '
假如您不是 <strong>' . $blogname . '</strong> 的治理员,请间接疏忽本邮件!</p></td></tr></table></td></tr></table></p></body></html>';
// 给网站治理员发送邮件
$message_headers = "Content-Type: text/html; charset="utf-8"n";
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message, $message_headers);
if ( emptyempty($plaintext_pass) )
return;

// 你能够在此修正发送给新用户的告诉Email,这里是HTML格局
$message = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>新用户注册</title></head><body><p align="center"><table cellpadding="0" cellspacing="1" style="border:3px solid #d9e9f1;background:#7fbddd; text-align:left;"><tr><td style="padding:0;"><table cellpadding="30" cellspacing="0" style="border:1px solid #ffffff;background:#f7f7f7;width:500px;"><tr><td style="line-height:2;font-size:12px;">您刚刚在网站 <strong>' . $blogname . '</strong> 注册一个帐号。
用户名:' . $user_login . '
登录明码:' . $plaintext_pass . '
登录网址:<a href="' . wp_login_url() . '">' . wp_login_url() . '</a>
假如您没有在 <strong>'. $blogname . '</strong> 注册过任何信息,请间接疏忽本邮件!</p></td></tr></table></td></tr></table></p></body></html>';
// sprintf(__('[%s] Your username and password'), $blogname) 为邮件题目
wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message, $message_headers);
}
endif;

两头的$message中的内容你本人爱怎样写就怎样写吧.

心愿本文所述对大家的WordPress建站有所协助。

以上就是安达网络工作室关于《WordPress修改新用户注册邮件内容的方法》的一些看法。更多内容请查看本栏目更多内容!

版权声明:本文为 安达网络工作室 转载文章,如有侵权请联系我们及时删除。
相关文章
如何在wordpress上添加文件上传的大小限度(多种完成办法)

本文只限Apache配置主机的应用办法,添加WordPress文件上传大小限度:经过配置php.ini的upload_max_filesiz...

解说WordPress开发中一些罕用的debug技巧

在开发进程中,调试代码是十分重要的工作,而把握一些 WordPress 的调试技巧,能够更好的进行调试。比方,在...

wordpress主题评论中增加回复的办法

本文实例讲述了wordpress主题评论中增加回复的办法。分享给大家供大家参考。详细如下: 很多冤家要给本人主...

wordpress首页显示摘要的几种办法小结

more标签 这种办法应该是最灵敏的一种办法,操作也很简略,只要要你在编辑文章的时分拔出more标签 或许应用...

PHP批量查问WordPress留言者E-mail地址完成办法

明天收到了很多Bloger冤家的E-mail拜年短信,嘿嘿,觉得很好玩,可是他们是如何完成的这个呢,很简略的,可...

WordPress中用于获取及自定义头像图片的PHP脚本详解

get_avatar()(获取头像) get_avatar() 函数用来获取置顶邮箱或许用户的头像代码,在评论列表中十分罕用。...

需求提交

客服服务

亿鸽在线客服系统