Sometimes you need to get a little creative when customizing the WordPress admin area. It’s often possible to do it without CSS, but it isn’t always straightforward: understanding what’s happening on the source files and digging through the many functions called in the ifs and elses is a must.
Here’s something slightly hacky I came up with, which should do the trick:
add_action('user_edit_form_tag', 'remove_unwanted_profile_options');
function remove_unwanted_profile_options() {
# Disable visual editor checkbox
global $wp_rich_edit_exists;
$wp_rich_edit_exists = false;
# Disable choice of admin color scheme from profile.php
remove_action('admin_color_scheme_picker', 'admin_color_scheme_picker');
}
The second bit is quite simple: just remove the action used by WP to generate the admin scheme picker. The gist of the first bit is this: WP uses the rich_edit_exists()
function to see if TinyMCE exists (i.e. script files have not been deleted by the administrator), but it will skip checking if the global variable $wp_rich_edit_exists
has been set; so we just set it to “false” before WP has the chance to parse our files. Quite simple, really. Plus, hooking everything to the ‘user_edit_form_tag
‘ action means this override only happens when viewing user-edit.php (which, by default, doesn’t use TinyMCE anyway).