Support » Plugin: WP-Members Membership Plugin » Hook for Subscriber password reset?

  • Resolved svacontact

    (@svacontact)


    Hi,

    I’d like to send email to the site admin (me) when a subscriber uses either the “forgot password” or “forgot username” links. I don’t want the body of the email containing the new password just a message containing the username and email address for the reset. It looks like hooks may be available, but not documented(?). Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    There are two action hooks – one for successful password change and one for successful password reset. As of 3.1.7 these are in the class-wp-members-user.php file. All filter and action hooks are documented inline in the plugin’s code regardless of whether they are in the plugin’s documentation or not, so you can always refer to the inline documentation to know what they are/do.

    They are:

    wpmem_pwd_change
    wpmem_pwd_reset

    You could hook a function to either of these to do what you need to. You can use wp_mail() within your function to send yourself a notification message of the successful action. Both actions pass the user ID, which can be used by your function to retrieve any user data you need about the user.

    • This reply was modified 2 years, 2 months ago by  Chad Butler.

    Thanks! Worked great. Here is the code I used if it will help anyone else.

    // 5/22/2017 Send email to admin on pwd reset
    add_action(‘wpmem_pwd_reset’, ‘pwd_reset_admin_email’);

    function pwd_reset_admin_email ($user_id) {
    $user_data = get_userdata( $user_id );
    $user = $user_data->data;
    $subject = “User Password Reset”;
    $admin_email = “youremail@youremail.com”;
    $message = sprintf( __( ‘This user has performed a password reset.’ ) ) . “\r\n\r\n”;
    $message .= sprintf( __( ‘Display Name: %s’ ), $user->display_name ). “\r\n\r\n”;
    wp_mail( $admin_email, $subject, $message);
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hook for Subscriber password reset?’ is closed to new replies.