Search code examples
phpwordpresswordpress-hook

WordPress - Hide personal settings from profile page


In profile page (where user could edit his details) there is part "Personal options" with "Admin color scheme" etc.

I know how to remove it with CSS / jQuery.

How could i remove that part with a hook/ filter / php code ?

Thanks.


Solution

  • This will 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' );
    

    Found here:

    https://wordpress.stackexchange.com/questions/49643/remove-personal-options-section-from-profile

    UPDATE

    Here is a JS (jQuery to be exact) hack as well...

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

    Found here:

    https://premium.wpmudev.org/blog/how-to-simplify-wordpress-profiles-by-removing-personal-options/