• Hello,
    Is there a way to Disable User Email Update for Subscribers(and other users) in profile update page? When the user registers with an email, I want to stop the user from changing the email after email confirmation.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • @imran_kanjoo Use this plugin: https://www.ads-software.com/plugins/modify-profile-fields-dashboard-menu-buttons/

    Or Use the following code:

    add_action( 'user_profile_update_errors', 'prevent_email_change', 10, 3 );
    
    function prevent_email_change( $errors, $update, $user ) {
    
        $old = get_user_by('id', $user->ID);
    
        if( $user->user_email != $old->user_email   && (!current_user_can('create_users')) )
                $user->user_email = $old->user_email;
    }

    Let me know if that works ??

    `

    Thread Starter Imran Kanjoo

    (@imran_kanjoo)

    Thank you for your reply.
    The plugin hides the fields only and does not add the code similar to your code.
    The provided code does not work. I have added it into child theme functions.php. I missed to mention that, I have a custom form at the front end which contains email box. specifically, I am using user registration plugin.

    Sorry for that @imran_kanjoo ??

    >>The plugin hides the fields only and does not add the code similar to your code.
    The provided code does not work<

    Yeah, the plugin is more of a workaround for people looking for a quick fix.

    >>I have a custom form at the front end which contains email box. specifically,<<

    Can you not disable it via UI?

    Let me know!

    `

    Thread Starter Imran Kanjoo

    (@imran_kanjoo)

    @soberbanda No, there is no such option in UI. May be I need to add some JavaScript to set it readonly. But I am afraid setting it readonly could be changed in browser as well. So there must be come code to check that similar to the code you provided previously.
    Or may be I need to go for plugin support.

    @imran_kanjoo That isn’t an issue with the plugin. You need a feature here.
    That part of code was for core WordPress profile functionality. It won’t work incase you are using a membership plugin.

    You can still try and ask here: https://www.ads-software.com/support/plugin/user-registration/
    Have a good day ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Disable User Email Update for Subscribers’ is closed to new replies.