How do you make the email field on the profile page read only for subscribers?

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');

Leave a Comment