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:
- Nickname
- Display name publicly as
- AIM, Yahoo, Google talk and About yourself fields
- 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.
functions.php
or a plugin file. As long as the hooks are right, it will work from either of the places.