I’d like to remove the action profile_personal_options
(more specifically the color scheme and visual editor checkbox) which shows up in wp-admin/user-edit.php
. I believe it’s as simple as running it through remove_action()
, but I’m not sure what the second parameter would be. Where would be the best place to look?
remove_action('profile_personal_options');
I was previously using:
function of_remove_profile_fields() {
if (current_user_can('manage_options') == false) {
?>
<style type="text/css">
form#your-profile p+h3,
form#your-profile p+h3+table { display:none!important;visibility:hidden!important; }
</style>
<?php }
}
add_action( 'admin_print_styles-profile.php', 'of_remove_profile_fields' );
add_action( 'admin_print_styles-user-edit.php', 'of_remove_profile_fields' );
but would rather do this the correct way. Thanks!
Update
Ack, this actually looks like it may be hardcoded into user-edit.php
. Should I just go with the CSS method? Is that area really required or WP? Why didn’t they plug into their own do_action('profile_personal_options', $profileuser);
?
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:
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).