Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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); ?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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).

share|improve this answer
    
+1 good approach and explanation –  userabuser Oct 12 '12 at 1:37
    
Very cool, thanks! –  Zach Oct 12 '12 at 13:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.