Forum Replies Created

Viewing 2 replies - 16 through 17 (of 17 total)
  • Hi!

    I don’t think WooCommerce has a straight setting to do this.

    You can add this code snippet in your themes’s functions.php and you should be good to go.

    The solution takes care of both front-end and back-end and displays an error to the user that their email cannot be modified.

    
    add_action( 'woocommerce_after_edit_account_form', 'disable_edit_email_address' );
    
    function disable_edit_email_address( ) {
        $script = '<script type="text/javascript">'.
                  'var account_email = document.getElementById("account_email");'.
                  'if(account_email) { '.
                  '     account_email.readOnly = true; '.
                  '     account_email.className += " disable-input";'.
                  '}'.
                  '</script>';
        echo $script;
    }
    
    add_action( 'woocommerce_save_account_details_errors', 'prevent_user_update_email', 10, 2 );
    
    function prevent_user_update_email( &$error, &$user ){
    	$current_user = get_user_by( 'id', $user->ID );
    	$current_email = $current_user->user_email;
    	if( $current_email !== $user->user_email){
    		$error->add( 'error', 'E-mail cannot be updated.');
    	}
    }
    

    I would recommend that you do this only if you are somewhat comfortable in adding code.

    This will prevent customers from editing their email themselves, but you can still edit users email if necessary from wp-admin->users.

    Thanks ??

    • This reply was modified 4 years, 10 months ago by Priya Gupta.

    Hi!

    I think you need to contact Printful folks to sort this out.

    I also tried your website and it worked fine for me.

    What I can suggest as a workaround for your problem is you may consider disabling default autocomplete for checkout fields.
    To do this you need to add this code to your themes function.php

    add_filter('woocommerce_checkout_get_value','__return_empty_string', 1, 1);
    (taken from https://stackoverflow.com/a/43319074)

    I would recommend that you do this only if you are somewhat comfortable in adding code. Also, know that this will disable autocomplete fields for all your users which is definitely not a good experience so, ideally the root cause should be identified and fixed.

Viewing 2 replies - 16 through 17 (of 17 total)