重置密码-更改名称和电子邮件地址

时间:2013-12-17 作者:Chris

当密码重置结束时,名称为“WordPress”,发件人地址为[email protected].我需要把这些改成公司名称。

我正在运行WordPress 3.8 multisite,并已完成以下操作:

更新了子网站的常规设置名称和电子邮件地址,安装了“WP Change email”插件并更新了详细信息,但这没有任何效果。我认为这是因为密码重置方面使用了不同的挂钩。

我正在使用以下代码(来自http://s14.codeinspot.com/q/2472332) 在函数中。php自定义密码重置标题和正文:

function my_retrieve_password_subject_filter($old_subject) {
    // $old_subject is the default subject line created by WordPress.
    // (You don\'t have to use it.)

    $blogname = wp_specialchars_decode(get_option(\'blogname\'), ENT_QUOTES);
    $subject = sprintf( __(\'[%s] Password Reset\'), $blogname );
    // This is how WordPress creates the subject line. It looks like this:
    // [Doug\'s blog] Password Reset
    // You can change this to fit your own needs.

    // You have to return your new subject line:
    return $subject;
}

function my_retrieve_password_message_filter($old_message, $key) {
    // $old_message is the default message already created by WordPress.
    // (You don\'t have to use it.)
    // $key is the password-like token that allows the user to get 
    // a new password

    $message = __(\'Someone has asked to reset the password for the following site and username.\') . "\\r\\n\\r\\n";
    $message .= network_site_url() . "\\r\\n\\r\\n";
    $message .= sprintf(__(\'Username: %s\'), $user_login) . "\\r\\n\\r\\n";
    $message .= __(\'To reset your password visit the following address, otherwise just ignore this email and nothing will happen.\') . "\\r\\n\\r\\n";
    $message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), \'login\') . "\\r\\n";

    // This is how WordPress creates the message. 
    // You can change this to meet your own needs.

    // You have to return your new message:
    return $message;
}

// To get these filters up and running:
add_filter ( \'retrieve_password_title\', \'my_retrieve_password_subject_filter\', 10, 1 );
add_filter ( \'retrieve_password_message\', \'my_retrieve_password_message_filter\', 10, 2 );
但是,我不知道如何扩展此功能以更改发件人名称和电子邮件地址?

2 个回复
最合适的回答,由SO网友:Maruti Mohanty 整理而成

您可以使用以下两个挂钩更改名称和电子邮件地址

在活动主题中使用以下内容functions.php 文件

add_filter( \'wp_mail_from\', \'wpse_new_mail_from\' );     
function wpse_new_mail_from( $old ) {
    return \'your email address\'; // Edit it with your email address
}

add_filter(\'wp_mail_from_name\', \'wpse_new_mail_from_name\');
function wpse_new_mail_from_name( $old ) {
    return \'your name or your website\'; // Edit it with your/company name
}

SO网友:mohamed arshath

在活动主题中使用以下代码functions.php 文件无需硬编码您的电子邮件地址和博客名称,这将在WordPress Settings>General中给出。

add_filter( \'wp_mail_from\', \'new_mail_from\' );
add_filter( \'wp_mail_from_name\', \'new_mail_from_name\' );
function new_mail_from( $old ) {
    return get_option( \'admin_email\' );
}
function new_mail_from_name( $old ) {
    return get_option( \'blogname\' ); 
}

结束

相关推荐

WP Cron emails not working

运行wp 3.5.1我有两个插件可以部分工作。他们做的每件事都很好。如果我点击发送电子邮件,他们就会发送电子邮件。然而scheduled 未发送电子邮件。插件包括:Wordpress file monitor plus 2.2版WP db manager 2.63版TROUBLESHOOTING我试着将时间表改为每小时、每天、每2天运行一次。但是他们没有一个人发送电子邮件,但其余的都完成了。WP db manager在正确的时间生成备份。Wordpress file monitor plus会在需要时检查