Сбросить пароль - изменить имя и адрес электронной почты
Когда произойдет сброс пароля, имя будет "WordPress", а адрес отправителя будет [email protected] . Мне нужно изменить их на название компании.
Я запускаю многосайтовый WordPress 3.8 и сделал следующее:
- Обновлены общие настройки имени и адреса электронной почты дочернего сайта
- Установлен плагин "WP Изменить адрес электронной почты" и обновлены сведения
Однако это не имеет никакого эффекта. Я думаю, это потому, что сторона сброса пароля вещи используют разные крючки.
Я использую следующий код (из http://s14.codeinspot.com/q/2472332 ) в functions.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 answers
Вы можете использовать следующие два крючка для изменения имени и адреса электронной почты
Используйте следующее в активной теме 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
}
Используйте следующий код в файле functions.php
вашей активной темы. Не нужно жестко кодировать свой адрес электронной почты и название блога, это делается так, как указано в настройках WordPress > Общие.
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' );
}