我需要调整在Wordpress后端中为用户更新密码后发送的电子邮件的文本。
我在我主题的functions.php中做到了:
add_filter('password_change_email', 'change_code');
我的功能:
function change_code($pass_change_mail,$user,$userdata ){
$new_message_txt = __( 'Some text ###USERNAME### more text even more text ###EMAIL### more text after more text last bit of text ###SITENAME###' );
$pass_change_mail[ 'message' ] = $new_message_txt;
return $pass_change_mail;
实际上,我需要在user.php中连接此过滤器,这会引起如下问题:
$pass_change_email = apply_filters( 'password_change_email', $pass_change_email, $user, $userdata );
$pass_change_email['message'] = str_replace( '###USERNAME###', $user['user_login'], $pass_change_email['message'] );
$pass_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $pass_change_email['message'] );
$pass_change_email['message'] = str_replace( '###EMAIL###', $user['user_email'], $pass_change_email['message'] );
$pass_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $pass_change_email['message'] );
$pass_change_email['message'] = str_replace( '###SITEURL###', home_url(), $pass_change_email['message'] );
wp_mail( $pass_change_email['to'], sprintf( $pass_change_email['subject'], $blog_name ), $pass_change_email['message'], $pass_change_email['headers'] );
也许代码未得到纠正,并且存在更好的东西。有人知道,如何解决这个问题?