Edit reset/lost password notification (4 posts)

  1. otta88sun
    Posted 1 year ago #

    HI, i want to delete the email sent to admin when user reset password but i want customize too the email sent to user.

    For now i created a plugin and wrote this:

    if ( !function_exists( 'wp_password_change_notification' ) ) {
    		function wp_password_change_notification(){
    			// do nothing

    But these just avoid admin notification on user reset password. Is there any way to change the content of email sent to user? Thank you

  2. davidsword
    Posted 1 year ago #

    check out retrieve_password() in wp-login.php it has a retrieve_password_message filter that may be of use.


  3. otta88sun
    Posted 1 year ago #

    I did this and work:

    function my_awesome_retrieve_password_message( $content, $key )
            $input = filter_input( INPUT_POST, 'user_login', FILTER_SANITIZE_STRING );
            if( is_email( $input ) )
                    $user = get_user_by( 'email', $user_login );
                    $user = get_user_by( 'login', sanitize_user( $input ) );
            $content = '<strong>'.get_bloginfo('name').' - Reimpostazione Password</strong><br/><br/>';
            $content .= sprintf( 'Ciao %s, รจ stata richiesta la reimpostazione della password per il tuo account<br/>', $user->first_name );
            $content .= 'Non cliccare sul link in basso se non hai effettuato la richiesta<br/>';
            $content .= sprintf( '%s?action=rp&key=%s&login=%s', wp_login_url('url'), $key, $input );
            return $content;
    add_filter ( 'retrieve_password_message', 'my_awesome_retrieve_password_message', 10, 2 );

    But the email is sent in text, any way to set it in html? Thank you.

  4. otta88sun
    Posted 1 year ago #

    i added this before return $content; at the end of the function.

    add_filter( 'wp_mail_content_type', 'set_html_content_type' );

    But have no idea how disable it, because disable it with

    remove_filter( 'wp_mail_content_type', 'set_html_content_type' );

    before end of function will disable html.

    However works without disabling it too.

Topic Closed

This topic has been closed to new replies.

About this Topic