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完成用户历史浏览记载性能分享

COOKIE记载SESSION记载数据库记载缓存文件记载从技术难度上,第1、2种办法最简略,因而,下文将完成以COOKI...

wordpress弱小的网站建立cformsII留言板插件

最近在做一个客户的企业网站建立时,需求往数据库提交信息的表单页面,然而Wordpress自带的评论性能来做的话...

WordPress完成评论提交后跳转的办法

很多采纳WordPress顺序搭建的博客都相当注重与读者之间的互动,以评论为例,为了进步读者的体验品质,有的博...

WordPress中用于创立以及获取侧边栏的PHP函数解说

register_sidebar()(创立侧边栏) 建设一个侧边栏,用来搁置小工具。这个函数应用的时分请放在一个函数里,...

Wordpress 的用户治理教程

要害字形容:教程 治理 用户 权限 能够 编辑 注册 Wordpress 咱们 后面咱们讲述了 Wordpress 插件的应用。...

wordpress增加顶级菜单完成思绪

比方本人创立了一个主题,那么需求在后盾增加一些设置选项,所以就触及到了后盾增加顶级菜单的需要: 复制代...

需求提交

客服服务

亿鸽在线客服系统