Shrek
Shrek

Reputation: 347

Setting email field read only

Using Woocommerce I've removed the shipping addresses/details from the checkout as they are not required but for logged in users I still want to show the email field but show it so it's not editable:

 if ( is_user_logged_in() ) {
    // change billing_email to read only
 } else {
    unset($fields['billing']['billing_email']);
 }

how is it I achieve this?

Upvotes: 1

Views: 1133

Answers (1)

rnevius
rnevius

Reputation: 27102

Each field can have custom attributes, stored as an array:

$fields['billing']['billing_email']['custom_attributes'] = array( 'readonly' => 'readonly' );

Upvotes: 3

Related Questions