• Resolved Jam

    (@dabert3)


    Hi Again,

    I would like to add validation on reset password page to check if the username or email does exist. So far I made this https://prntscr.com/26jh4ih. The error message will show up base on URL parameter. Here’s the code I use:

    add_action( 'um_reset_password_errors_hook', 'my_reset_password_errors', 10, 1 );
    function my_reset_password_errors( $post ) {
       
        $email = email_exists( $post['username_b'] );
        $username = username_exists( $post['username_b'] ); 
        if( !$email || !$username ){
        	wp_redirect( get_site_url() . '/reset-password/?updated=checkemail' ); 
        }else{
        	wp_redirect( get_site_url() . '/reset-password/?user=0' ); 
        }
        exit;
    } 

    But the problem, The Password email notification won’t send or receive to user email. What is the best hook for this or any suggest would be appreciated.

    Best Regards,

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @dabert3

    Can you please confirm that you want to show an error when the username or email exists on your site on form submission?

    Regards,

    Thread Starter Jam

    (@dabert3)

    Hello @champsupertramp

    Yes that is correct

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @dabert3

    You can try this code snippet:

    add_action("um_after_email_notification_sending","um_012722_redirect_after_sending_password_reset",10, 2);
    function um_012722_redirect_after_sending_password_reset( $user_email, $template ){
     
        if( "resetpw_email" == $template && um_is_core_page("password-reset") ){ 
           $email = email_exists( $_REQUEST['username_b'] );
           $username = username_exists( $_REQUEST['username_b'] ); 
           if( !$email || !$username ){
           	wp_redirect( get_site_url() . '/reset-password/?updated=checkemail' ); 
           }else{
        	wp_redirect( get_site_url() . '/reset-password/?user=0' ); 
           }
           exit;
        }
    }

    Regards,

    Thread Starter Jam

    (@dabert3)

    Okay this should work. Thanks! great as always!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Thanks for letting us know.

    Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add validation on Reset password’ is closed to new replies.