• Resolved aoi0515

    (@aoi0515)


    Hi,
    I want to disable for users chaging email adress on profile detail page.
    Is that possible to do this?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Saroj Shah

    (@wpeverestsupportrep)

    Hi @aoi0515

    Thanks for writing in,

    Please go to:
    user-registration/includes/form/class-ur-form-field-user-email.php
    and replace the lines from 50 t0 73 with the following code.

    public function validation( $single_form_field, $form_data, $filter_hook, $form_id ) {
    
                    $email  = isset( $form_data->value ) ? $form_data->value : '';
                    $status = is_email( $email );
    
                    if ( email_exists( $email ) ) {
    
                             // On multisite, ensure user exists on current site
                            if ( is_multisite() ) {
                                    // assign user to blog and set their status to pending 
                                    $user_data = get_user_by( 'email', $email ); 
                                    if ( $user_data && ! is_user_member_of_blog( $user_data->ID, get_current_blog_id() ) ) {
                     
                                            add_user_to_blog( get_current_blog_id(), $user_data->ID, 'customer' );
                                            
                                            $user_manager = new UR_Admin_User_Manager( $user_data->ID );
                                            $user_manager->save_status( $status, $alert_user=false );
                                    
                                    } else {
                                            $error='Email alaredy exists on this site.';
                                    }
                             } else {
                                    $error='Email alaredy exists.';
                            }
    
                            if($error)
                                    add_filter(
                                            $filter_hook,
                                            function ( $msg ) {
                                                    return __( $error, 'user-registration' );
                                            }
                                    );
                    }
            }

    I hope this helps.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Disable changing email address’ is closed to new replies.