Disable the users ability to change their email address

Hello,

I am having issues with customers giving other people access to their account, and when that other person goes to checkout, they change the account email address to their own.

This causes issues on our backend customer fulfilment process.

Is there a way to disable the users ability to change their email address?

Thanks in advance!

  • Alex Stine
    • System Administrator

    Hello Matt
    Hope you are well today!

    Could you please try this custom code? You can add it to your themes functions.php file or you can use a mu-plugin.

    /*Remove Email Field From WordPress Admin*/
    /*Define our function*/
    function wpmu_hide_email_field() {
    /*Restrict To Certain Admin Pages*/
    global $pagenow;
    if ($pagenow!=='profile.php' && $pagenow!=='user-edit.php') {
    return;
    }
    /*Exclude Admins From The Removal*/
    if (current_user_can('edit_users') ) {
    /*If User Does Not Have Capability, Hide Field*/
    } else {
    echo '<style type="text/css">
    tr.user-email-wrap {
    display: none;
    }
    </style>';
    }
    }
    /*Hook In To Admin Header For Loading The CSS*/
    add_action( 'admin_head', 'wpmu_hide_email_field' );

    Hope this helps!

    Cheers,
    Alex :smiley:

  • Alex Stine
    • System Administrator

    Hello Matt
    Hope you're well today!

    Sorry about that, my code above removes the Email field inside of WordPress Admin. This code should remove the billing email from the front end, could you please give it a try?

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    function custom_override_checkout_fields( $fields ) {
    unset($fields['billing']['billing_email']);
    return $fields;
    }

    Please let me know if this helps.

    Cheers,
    Alex :smiley:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.