How to remove these fields from the ‘Profile’ section?

I have to remove some profile fields from the ‘Profile’ page according to the user roles. For removing the color picker I used remove_action("admin_color_scheme_picker", "admin_color_scheme_picker"). I want to remove these fields:

  1. Nickname
  2. Display name publicly as
  3. AIM, Yahoo, Google talk and About yourself fields
  4. The ‘Show Admin Bar’ section along with the 2 checkboxes

I went through the file ‘user-edit.php’ to see if there are any actions/filters that allow me to do so, but it seems there aren’t.
Can anyone tell me how to do this? Any help would be appreciated.
Thanks

EDIT:
Thanks @helenhousandi for the answer. I had already did it this way though.

<?php
add_action('admin_footer-profile.php', 'remove_profile_fields');
function remove_profile_fields()
{
    if(current_user_can('custom_role'))
    { ?>
        <script type="text/javascript">
            jQuery("h3:contains('Personal Options')").next('.form-table').remove();
            jQuery("h3:contains('Personal Options')").remove();
            jQuery("h3:contains('About Yourself')").next('.form-table').remove();
            jQuery("h3:contains('About Yourself')").remove();
        </script>
<?php }
}
?>

I know this is a bit longer, but it worked! I think I’ll go with @helenhousandi’s answer.

7

For the contact methods filter: user_contactmethods:

function update_contact_methods( $contactmethods ) {

    unset( $contactmethods['aim'] );
    unset( $contactmethods['jabber'] );
    unset( $contactmethods['yim'] );

    return $contactmethods;

}
add_filter( 'user_contactmethods', 'update_contact_methods' );

Leave a Comment