D7 - Webform Email Field Read Only We would like to target a webform field "email" so that it only has readonly option when the field uses the logged in users email address.

The webform email field has an option to "Set the default value of this field to the user email, if he/she is logged in." and to toggle a "readonly" option.

How would we go about achieving this?
There's two possible approaches you could take here:


Add a custom hook_form_alter to test in php if the user is logged in, and then set the disabled/locked attribute to the field.
Add javascript that on page load checks to see if the body has the "logged-in" class and if the field is already populated/has a value; then disable/lock it.