• Im trying to add a custom function in “Functions.php” that will send me an email to my admin email address if a member clicks on “Forgot Password?” on the https://www.darwendt.com/customer-area/ page.

    This is the code I am trying, but the section doesnt seem to be called as I belive I dont have the correct hook name in the add_action line.

    Could anybody possibly point me in the wright direction if this is possible to do.

    Regards Andrew….

    add_action( ‘wpmem_pwd_reset_email_sent’, ‘notify_admin_wpmem_pwreset_requested’, 10, 1 );

    function notify_admin_wpmem_pwreset_requested( $user_id ) {
    // — START DEBUGGING LINE —
    error_log( ‘DEBUG: notify_admin_wpmem_pwreset_requested function triggered for user ID: ‘ . $user_id );
    // — END DEBUGGING LINE —

    $admin_email = 'MY_EMAIL_IS_HERE'; // Your admin email address

    $user = get_userdata( $user_id );
    if ( ! $user ) {
    error_log( 'WP-Members Password Reset Request Notification: User data not found for ID ' . $user_id );
    return;
    }

    $user_login = $user->user_login;
    $user_email = $user->user_email;

    $subject = 'WP-Members Password Reset Request - EMAIL SENT';
    $message = "A WP-Members password reset link was requested and sent to a user:\n\n";
    $message .= "Username: $user_login\n";
    $message .= "Email: $user_email\n";
    $message .= "Time: " . current_time( 'Y-m-d H:i:s' ) . "\n";
    $message .= "Site: " . get_bloginfo('name') . "\n";
    $message .= "Site URL: " . site_url();

    // Send the email
    $mail_sent = wp_mail( $admin_email, $subject, $message );

    if ( ! $mail_sent ) {
    error_log( 'WP-Members Password Reset Request Notification: Failed to send email to ' . $admin_email );
    } else {
    // --- START DEBUGGING LINE ---
    error_log( 'DEBUG: notify_admin_wpmem_pwreset_requested email successfully sent to ' . $admin_email );
    // --- END DEBUGGING LINE ---
    }

    }

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

    (@cbutlerjr)

    Action hooks have to exist in the plugin (or WordPress) to be able to hook a function to them. There is no wpmem_pwd_reset_email_sent action.

    There isn’t a specific action hook in the email send process at this point. However, it does make sense to add one so that functions like this could be hooked to it. I’ll probably look at adding one in the next release.

    In the meantime, since you want this an the sending process, it’s probably best to look for an existing hook that is as late in the process as possible. You could use WP’s wp_mail_succeeded, but you’d need to make sure you check the $mail_data param that is passed to see if it’s the password reset (you can do that by checking the value of $mail_data['subject']

Viewing 1 replies (of 1 total)

The topic ‘Hooks for password reset and reset complete’ is closed to new replies.