Filtering 'retrieve_password_message' using the Theme My Login WordPress plugin

admin

Administrator
Staff member
I'm using the <a href="http://wordpress.org/plugins/theme-my-login/" rel="nofollow">Theme My Login</a> WordPress plugin. My aim is to filter 'retrieve_password_message' - Just to make some minor text changes to the email that gets sent out when a user requests a password reset.

My code:

Code:
function filter_reset_password_request_email_body( $message, $key, $user_id ) {

    $user_login = bp_core_get_username( $user_id );

    $message .= sprintf( __( 'Password reset request for %s' ), $user_login ) . "\r\n\r\n";
    $message .= __( 'If this was not you, please ignore this email and nothing will happen.' ) . "\r\n\r\n";
    $message .= __( 'To reset your password, visit the following link:' ) . "\r\n\r\n";
    $message .= network_site_url( "wp-login.php?action=rp&amp;key=$key&amp;login=" . rawurlencode( $user_login ), 'login' ) . "\r\n";

    return $message;
}
add_filter( 'retrieve_password_message', 'filter_reset_password_request_email_body', 10, 3 );

The problem is - when using this filter, the email that gets sent out displays the filtered message directly underneath the original (unfiltered) message. I just need the filtered message to display in the email body.

Am I doing anything wrong or could this be a bug with Theme My Login?

Hoping somebody can throw some light on this.

<strong>Notes:</strong> I'm using BuddyPress which is why I can use
Code:
bp_core_get_username
to get the user's username.