繁体   English   中英

使用wordpress中的密码编辑密码更新电子邮件给用户

[英]Edit password update email to user with password in wordpress

嗨,我想编辑密码更改电子邮件的模板,当管理员更改用户密码时,我想通过电子邮件将密码发送给用户,我尝试编辑代码,但没有用。 这是我的代码

.
if ( ! empty( $send_password_change_email ) ) {
            /* translators: Do not translate USERNAME, ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
            $pass_change_text = __( 'Hi ###USERNAME###,

This notice confirms that your password was changed on ###SITENAME###.
your new password is this :###PASSWORD###
If you did not change your password, please contact the Site Administrator at
###ADMIN_EMAIL###

This email has been sent to ###EMAIL###

Regards,
All at ###SITENAME###
###SITEURL###' );

            $pass_change_email = array(
                'to'      => $user['user_email'],
                /* translators: User password change notification email subject. 1: Site name */
                'subject' => __( '[%s] Notice of Password Change' ),
                'message' => $pass_change_text,
                'headers' => '',
            );

            /**
             * Filters the contents of the email sent when the user's password is changed.
             *
             * @since 4.3.0
             *
             * @param array $pass_change_email {
             *            Used to build wp_mail().
             *            @type string $to      The intended recipients. Add emails in a comma separated string.
             *            @type string $subject The subject of the email.
             *            @type string $message The content of the email.
             *                The following strings have a special meaning and will get replaced dynamically:
             *                - ###USERNAME###    The current user's username.
             *                - ###ADMIN_EMAIL### The admin email in case this was unexpected.
             *                - ###EMAIL###       The user's email address.
             *                - ###SITENAME###    The name of the site.
             *                - ###SITEURL###     The URL to the site.
             *            @type string $headers Headers. Add headers in a newline (\r\n) separated string.
             *        }
             * @param array $user     The original user array.
             * @param array $userdata The updated user array.
             *
             */
            $pass_change_email = apply_filters( 'password_change_email', $pass_change_email, $user, $userdata );
            $pass_change_email['message']=str_replace( '###PASSWORD###',$user['user_password'], $pass_change_email['message'] );
            $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'] );
        }

有谁知道如何为用户获取管理员更改的密码?

如果在管理员单击“更新配置文件”按钮的同时触发了电子邮件发送,则可以使用发布数据: $_POST['pass1'] (或$_POST['pass1-text'] )。 您可以将行更改为如下

$pass_change_email['message']=str_replace( '###PASSWORD###',$_POST['pass1'], $pass_change_email['message'] );

如果这些电子邮件是异步生成的,那么您可能无法获得该值,因为通常会对密码进行哈希处理。 不建议这样做,但一种解决方法是将密码另存为自定义字段中的计划文本,发送电子邮件,然后删除该自定义字段。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM