Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Confirmation required on email change

Discussion in 'Misc WordPress Requests' started by anurag.deshmukh, Mar 13, 2018.

  1. anurag.deshmukh

    Guest

    Reply To: Confirmation required on email change, by anurag.deshmukh

    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.

    Reply To: Confirmation required on email change
     
    #1

Share This Page

Monarch Social Sharing Plugin