How to Hide or Remove User Role Selection on the WordPress Edit Profile Page
The easiest way to hide the role dropdown is by using some custom CSS. This method will hide the role field but technically, it remains in the HTML, just hidden.
function hide_role_selection_in_profile() {
echo '<style>.user-role-wrap { display: none; }</style>';
}
add_action('admin_head', 'hide_role_selection_in_profile');
The admin_head
hook is used to inject custom styles directly into the WordPress admin.
The CSS targets the .user-role-wrap
class on the profile page, and hides it by setting display:none
.