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 主动在注释内容后增加内容

但在制造主题的时分,每个用户的需要都不同,而且你也不可能在文章下方增加太多的内容。因而让用户能自定义...

Ubuntu效劳器上的最优WordPress计划

WordPress是一个经典而又弱小的博客顺序,并且易于装置与搭建,在OpenShift上不花半分钟就能够收费建起一个...

Wordpress迁徙后图片地址谬误成绩的处理办法

WordPress改换空间后 需求调整的几个中央? 1.数据库衔接配置文件 wp-config.php 2.查看.htaccess文件,并修...

wordpress定时义务(wp-cron.php)造成主机CPU比拟高的处理方法

自从用了阿里云主机,真是没有省心过。 这两天网站CPU天天100+的,过一会就挂了,原来是wp-cron.php文件造成...

WordPress中邮件的一些修正和自定义技巧

更改邮件内容类型为 HTML 在 WordPress 中发送邮件需求应用 wp_mail() 函数,然而邮件内容默许的类型却是“...

wordpress文章题目为空时其它内容替代的办法

在WordPress中时常存在某些文章不需求题目的状况,特地是在一些集体网站,他们经常应用一些不需求题目的pos...

需求提交

客服服务