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 3.0+菜单性能支持二级和N级菜单完成步骤

自带的导航菜单性能是 WordPress 3.0+ 中惟一执得让人眼睛一亮的性能了,在新做主题的进程中再一次让我眼睛...

获取wordpress注册用户的数量的办法

本文实例讲述了获取wordpress注册用户的数量的办法分享给大家供大家参考。详细完成办法如下: 办法一,代码如...

WordPress评论邮件告诉无插件完成思绪及代码

通常咱们喜爱应用Wordpress Thread Comment 或 Mail To Commenter这两款插件前者久未更新,已测支持WordPre...

wordpress与人人网文章同步操作教程

很多冤家都在应用Wordpress写集体博客,然而又想把写的博客文章同步到其余的社交网站上,比方人人网,那怎样...

WordPress建站有哪些劣势

  你还没决议应用什么软件来构建你的新公司网站吗? 依然以为WordPress只是搭建博客吗? 在互联网上有大约2...

WordPress装置图解教程

1 下载并解紧缩&ldquo;WordPress&rdquo;,英文版能够到WordPress民间网站下载,中文版能够到WordPress中文论...

需求提交

客服服务