Wordpress 检索\u密码\u消息与我用于密码检索消息的方式不一样
我使用了下面的代码。但它不起作用Wordpress 检索\u密码\u消息与我用于密码检索消息的方式不一样,wordpress,Wordpress,我使用了下面的代码。但它不起作用 function site_change_password_mail_message( $message, $key ) { $message = __( 'Hi ###USERNAME###, This notice confirms that your password was changed on JDRF. If you did not change your password, please contact JDRF Support at siteu
function site_change_password_mail_message( $message, $key ) {
$message = __( 'Hi ###USERNAME###,
This notice confirms that your password was changed on JDRF. If you did not change your password, please
contact JDRF Support at siteurl.com/inquiry. This email has been sent to ###EMAIL###.
Regards,
All at siteurl.com
[Application Homepage, ex. ###SITEURL###]');
return $message;
}
add_filter( 'retrieve_password_message', 'site_change_password_mail_message', 10, 3 );
我应该换这个吗?我仍然收到这个消息
Hi ranjit,
Someone has requested a new password for the following account on K Gems & Crystals:
Username: username
If you didn't make this request, just ignore this email. If you'd like to proceed:
Click here to reset your password
Thanks for reading.
我可以看出您没有使用正确的参数来筛选您正在使用的内容。您需要对筛选器使用适当的参数。试试这个代码
add_filter( 'retrieve_password_message', 'retrive_reset_password_msg', 10, 4 );
function retrive_reset_password_msg( $message, $key, $user_login, $user_data ) {
$message = __( 'Hi ###USERNAME###,
This notice confirms that your password was changed on JDRF. If you did not change your password, please
contact JDRF Support at siteurl.com/inquiry. This email has been sent to ###EMAIL###.
Regards,
All at siteurl.com
[Application Homepage, ex. ###SITEURL###]');
return $message;
}
如果您要在注册用户后发送电子邮件,并且希望更改wordpress的默认电子邮件。您应该使用这个小代码
add_fileter("wp_new_user_notification_email", "callback",10,3);
function callback( $message, $user, $blogname) {
$message['headers'] = array('Content-Type: text/html; charset=UTF-8');
$message['subject'] = sprintf( '[%s] Site Name.', $blogname );
$message['message'] = sprintf( "%s ( %s ) has registerd to your blog %s.",
$user->user_login, $user->user_email, $blogname );
return $message;
}
如果是发送更改密码的电子邮件
function filter_retrieve_password_message( $message, $key, $user_login, $user_data ) {
// make filter magic happen here...
return $message;
};
// add the filter
add_filter( 'retrieve_password_message', 'filter_retrieve_password_message', 10, 4 );