11

I want to hide/remove the Personal Options in the Your Profile (wp-admin/profile.php) admin page.

I am aware that solutions for this exist, but I they use jQuery to do hide this section. This works, but when a user has JavaScript disabled in their browser, it will show up again. Therefore it is not a proper way to remove Personal Options.

Is there a way to remove the Personal Options section from the HTML source of the page? This means no jQuery or CSS hacks, or core file modification.

24

This should do the trick

// removes the `profile.php` admin color scheme options
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );

if ( ! function_exists( 'cor_remove_personal_options' ) ) {
  /**
   * Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options.
   */
  function cor_remove_personal_options( $subject ) {
    $subject = preg_replace( '#<h3>Personal Options</h3>.+?/table>#s', '', $subject, 1 );
    return $subject;
  }

  function cor_profile_subject_start() {
    ob_start( 'cor_remove_personal_options' );
  }

  function cor_profile_subject_end() {
    ob_end_flush();
  }
}
add_action( 'admin_head-profile.php', 'cor_profile_subject_start' );
add_action( 'admin_footer-profile.php', 'cor_profile_subject_end' );

Also, don't forget to mark your previous questions as solved :)

  • this is awesome, but how do i make it work for WP 3.4? only the color scheme picker is removed. probably bec i can't seem to find the files admin_head-profile.php and admin_footer-profile.php in the core. ideas? thanks much. – Ana Ban Jun 26 '12 at 11:20
  • Are you sure it doesn't work? I just used this on a new installation and it worked OK. Note you have to edit above code if you're using some other language. Also, here's some info about admin_head-profile.php and admin_footer-profile.php: codex.wordpress.org/Plugin_API/… – user5424 Jun 26 '12 at 18:46
  • @CorvanNoorloos Thanks for this, is there any way to leave the option to allow them to check if they want to show the toolbar or not? – Greenhoe May 17 '15 at 1:46
6

Was just trying to figure this out and came across this answer. The above code by Cor van doesn't work anymore, but with a slight change of the add_action, it can.

All you need to do is change the last two lines from:

add_action( 'admin_head-profile.php', 'cor_profile_subject_start' );
add_action( 'admin_footer-profile.php', 'cor_profile_subject_end' );

to

add_action( 'admin_head-user-edit.php', 'cor_profile_subject_start' );
add_action( 'admin_footer-user-edit.php', 'cor_profile_subject_end' );

So, the final code would look something like:

if ( ! function_exists( 'cor_remove_personal_options' ) ) {
  /**
   * Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options.
   */
  function cor_remove_personal_options( $subject ) {
    $subject = preg_replace( '#<h3>Personal Options</h3>.+?/table>#s', '', $subject, 1 );
    return $subject;
  }

  function cor_profile_subject_start() {
    ob_start( 'cor_remove_personal_options' );
  }

  function cor_profile_subject_end() {
    ob_end_flush();
  }
}
add_action( 'admin_head-user-edit.php', 'cor_profile_subject_start' );
add_action( 'admin_footer-user-edit.php', 'cor_profile_subject_end' );
  • Nice follow up, this change to the original code worked perfectly. – Daniel Feb 13 '14 at 2:31
  • Could you tell me how can I remove more <h3> elements? What modifications of the above code do I need? – humpdi Jan 27 '16 at 18:35
5

Accepted answer is not working with 4.8

Here comes an up to date and simplified code that should work with any version:

        // removes admin color scheme options

        remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );

        //Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options.

        add_action( 'admin_head', function () {

            ob_start( function( $subject ) {

                $subject = preg_replace( '#<h[0-9]>'.__("Personal Options").'</h[0-9]>.+?/table>#s', '', $subject, 1 );
                return $subject;
            });
        });

        add_action( 'admin_footer', function(){

            ob_end_flush();
        });     
  • 1
    +1 but same problem as with accepted answer, the string needs to be localized for it to work with non english laguages. – Mark Kaplun Jun 16 '17 at 14:36
  • @MarkKaplun thats right! I made the change. – RafaSashi Jun 16 '17 at 15:50
3

Thanks to the comment from @Per I got it working for 4.5.2

    // removes admin color scheme options
    remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );

    if ( ! function_exists( 'cor_remove_personal_options' ) ) {
        /**
        * Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options.
        */
        function cor_remove_personal_options( $subject ) {
            $subject = preg_replace( '#<h2>Personal Options</h2>.+?/table>#s', '', $subject, 1 );
            return $subject;
        }

        function cor_profile_subject_start() {
            ob_start( 'cor_remove_personal_options' );
        }

        function cor_profile_subject_end() {
            ob_end_flush();
        }
    }
    add_action( 'admin_head', 'cor_profile_subject_start' );
    add_action( 'admin_footer', 'cor_profile_subject_end' );`
2

Update for 3.9, the following works:

add_action( 'admin_head', 'cor_profile_subject_start' );
add_action( 'admin_footer', 'cor_profile_subject_end' );
0

I just wanted to clarify that the code will not work for localized versions of WordPress, because of the hardcoded Personal Options string. I cannot think of any easy solution here, but suggestions are welcome.

I would have added this as a comment, but I haven't got enough reputation to add a comment.

I also take this opportunity to re-paste the whole code updated for WordPress version 3.9.

Here it is:

// removes the `profile.php` admin color scheme options
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );

if ( ! function_exists( 'cor_remove_personal_options' ) ) {
  /**
   * Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options.
   */
  function cor_remove_personal_options( $subject ) {
    $subject = preg_replace( '#<h3>Personal Options</h3>.+?/table>#s', '', $subject, 1 );
    return $subject;
  }

  function cor_profile_subject_start() {
    ob_start( 'cor_remove_personal_options' );
  }

  function cor_profile_subject_end() {
    ob_end_flush();
  }
}
add_action( 'admin_head', 'cor_profile_subject_start' );
add_action( 'admin_footer', 'cor_profile_subject_end' );

Again, if you know in advance what the language of your WP installation will be, change the Personal Options string to the localized version of your language, for example in Italian you will replace it with Impostazioni personali.

0

By using

$subject = preg_replace( '#<h3>'.__("Personal Options").'</h3>.+?/table>#s', '', $subject, 1 );

in the cor_remove_personal_options function, it is localized as well.

0

I´ve found this solution on: https://premium.wpmudev.org/blog/how-to-simplify-wordpress-profiles-by-removing-personal-options/?ptm=c&utm_expid=3606929-108.O6f5ypXuTg-XPCV9sY1yrw.2

function hide_personal_options(){ 
    echo "\n" . '<script type="text/javascript">jQuery(document).ready(function($) { 
    $(\'form#your-profile > h3:first\').hide(); $(\'form#your-profile > 
    table:first\').hide(); $(\'form#your-profile\').show(); });</script>' . "\n"; 
} 
add_action('admin_head','hide_personal_options');

If you want to be more specific or remove more you should have a look over here: https://isabelcastillo.com/hide-personal-options-wordpress-admin-profile

You can just add those lines into the function.

  • Removing it with Javascript is never a good practice... – Marcos Buarque Jul 16 '18 at 3:44
0

Here's my CSS solution, tested in Wordpress 4.9.8

remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
add_action( 'admin_head', function(){
    ob_start(); ?>
    <style>
        #your-profile > h2,
        .user-rich-editing-wrap,
        .user-syntax-highlighting-wrap,
        .user-comment-shortcuts-wrap,
        .user-admin-bar-front-wrap {
            display: none;
        }
    </style>
    <?php ob_end_flush();
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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