我需要以下脚本的帮助
public function replace_retrieve_password_message( $message, $key, $user_login, $user_data ) {
// Create new message
$msg = __( 'Hello!', 'personalize-login' ) . "rnrn";
$msg .= sprintf( __( 'You asked us to reset your password for your account using the email address %s.', 'personalize-login' ), $user_login ) . "rnrn";
$msg .= __( "If this was a mistake, or you didn't ask for a password reset, just ignore this email and nothing will happen.", 'personalize-login' ) . "rnrn";
$msg .= __( 'To reset your password, visit the following address:', 'personalize-login' ) . "rnrn";
$msg .= site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . "rnrn";
$msg .= __( 'Thanks!', 'personalize-login' ) . "rn";
return $msg;
}
这将替换 WordPress重置密码电子邮件。它的功能很好,正在享受待遇。但是,它不是很漂亮,我想用HTML
电子邮件代替它。
有没有一种方法可以将HTML
添加到此处,并且仍然保留>打印URL和用户电子邮件地址的功能?例如;
<div>
<h1>Hello</h1>
<p>You asked us to reset your password for your account using the email address <?php PRINT USER EMAIL ?></p>
<a href="<?php PRINT URL ?></a>
</div>
我知道以上是非常基本的,并且PHP
不正确,但是如果我想用此替换Plain Text
电子邮件,我该怎么办?是否可以使用HTML
内容创建一个单独的PHP
文件和return
此模板中的内容?
您的时间总是非常感谢。
我问题的解决方案是在两个部分中完成的
首先是添加到functions.php
function email_set_content_type(){
return "text/html";
}
add_filter( 'wp_mail_content_type','email_set_content_type' );
第二次在自定义插件中添加,如下所示
$msg = __( "<div><h1>Hello!</h1>", 'personalize-login' ) . "rnrn";
$msg = __( "<p>You asked us to reset your password for your account using the email address", 'personalize-login' ) . "rnrn";
$msg .= sprintf( __( "%s.</p>", 'personalize-login' ), $user_login ) . "rnrn";
$msg .= __( "<a href='", 'personalize-login' ) . "rnrn";
$msg .= site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . "rnrn";
$msg .= __( "'></a></div>", 'personalize-login' ) . "rnrn";
return $msg;
我现在使用此方法将所有核心WordPress消息替换为整个email
模板,包括html
body
和head
标签。
感谢您对我解决方案有输入的人。
是的,达伦·马瑟斯(Darren Mathers),您可以使用
之类的东西function replace_retrieve_password_message($message, $key, $user_login, $user_data) {
// Create new message
$msg = '<div><h1>Hello!, personalize-login</h1>';
$msg .= '<p>You asked us to reset your password for your account using the email address personalize-login </p>'.$user_login;
$msg .= "<p>If this was a mistake, or you didn't ask for a password reset, just ignore this email and nothing will happen personalize-login";
$msg .= '<p> To reset your password, visit the following address: personalize-login';
$msg .= '<p>'.site_url( "wp-login.php?action=rp&key=$key&login=".rawurlencode($user_login),'login').'</p>'
$msg .= '<p>Thanks! personalize-login</p> </div>';
return $msg;
}