• holdusback

    (@holdusback)


    Hey there, is there an option to confirm the email change with a link ?

    This can be really usefull to prevent fake or mistyped email address.

    something like :
    1: user changes his/her mail
    2: Admin/website send confirmation email.
    3: If the user confirm that email by clicking confirmation link, then the email should be changed.

    PS : I use Ultimate Members has membership plugin.

    Hope someone can help me !

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • anurag.deshmukh

    (@anuragdeshmukh)

    You can paste below code in your current theme’s functions.php file

    
    1. If user changes email address from his/her profile
    function update_profile_email_adddress( $user_id, $old_user_data ) {
     
      $user = get_userdata( $user_id );
      if($old_user_data->user_email != $user->user_email) {
        $admin_email = "[email protected]";
        $msg = sprintf( __( 'Below user has updated their profile.' ) ) . "\r\n\r\n";
        $msg .= sprintf( __( 'User Name: %s' ), $user->display_name ). "\r\n\r\n";
        $msg .= sprintf( __( 'Previous Email: %s' ), $old_user_data->user_email ). "\r\n\r\n";
        $msg .= sprintf( __( 'New Email: %s' ), $user->user_email ). "\r\n\r\n";
        wp_mail( $admin_email, sprintf( __( '[Your Site Name] User Profile Update' ), get_option('blogname') ), $msg );
      }
     
    }
    
    add_action( 'profile_update', 'update_profile_email_adddress', 10, 2 );
    
    2. Admin/website send confirmation email. || This will be similar when new user registers on your site
    
    if ( !function_exists('wp_new_user_notification') ) {
        function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
            $user = new WP_User($user_id);
      
            $user_login = stripslashes($user->user_login);
            $user_email = stripslashes($user->user_email);
      
            $message  = sprintf(__('New user registration on your website. %s:'), get_option('blogname')) . "rnrn";
            $message .= sprintf(__('Username: %s'), $user_login) . "rnrn";
            $message .= sprintf(__('E-mail: %s'), $user_email) . "rn";
      
            wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message);
        }
    }
    

    Hope this helps.

    Thread Starter holdusback

    (@holdusback)

    Hey there,

    Big thanks for you’re code. But when I speak about confirmation I mean a link (with a key) to confirm changing email address.

    Like 80% of the website right now, when you want to change you’re email address you have to click on a personnal link sended on you’re current email address

    Anyways, you’re code is a good start I think. Hope someone else see this topic.

    anurag.deshmukh

    (@anuragdeshmukh)

    Where is the user redirected when he/she clicks on personal link ? There might be any profile manageable page from where user can update the details.

    Is there any plugin used for that or it’s WP default ?

    If that has been any form, and on submitting of that form, email gets updated, we can apply code on form submission and can check if old email and new email is different, we can notify to admin.

    Thread Starter holdusback

    (@holdusback)

    Hey there, Sorry for the late reply.

    I can code a page with a small form for the new email.

    Im using Ultimate member right now as community plugin, so they have an account page when they can change their email.

    Thanks man !

    Have a good week end.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Confirmation required on email change’ is closed to new replies.