Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to make the email field on the profile page for subscribers read only. They can see their email but not change it. I want only admins to to be able to change users email address.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Although the readonly attribute can be removed using Chrome/Firebug inspector (making the field editable again), much probably the average user will not know this.

<?php
function wpse50730_script_enqueuer(){
    if(current_user_can('subscriber')) {
        echo '<script type="text/javascript">
        jQuery(document).ready( function($) {
            $(".form-table #email").attr("readonly", true);
        });     
        </script>';
    }
}
add_action('admin_head-profile.php', 'wpse50730_script_enqueuer');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.