0

Do not misunderstood.

I am trying to remove/disable Show toolbar option (not talking about hide/disable admin bar) but talking about The Option into Profile Settings.

I tried to search but in all I found only how to disable admin bar from front and back but nowhere I found how to remove the check-boxes from profile settings.

1

the fields are hard coded there is nog filter or action to disable it.
You could hide it with CSS....

If you want you could replace the entirely page with a different one you custom create.

  • Actually I was looking proper and technical solution but css hack is also fine for now. Thanks! – pixelngrain Jun 5 '12 at 7:34
2

@pixelngrain , Maybe this is what you where looking for, this part of code will at least hide the Personal Options.

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

This in functions.php works like a charm for me. Code found here : Remove personal options

1

Using the answer provided to the question Remove Personal Options section from Profile, you can remove the entire block of 'Personal Options' from the profile/user edit screens. By adapting the approach in the top answer there, you can specifically target the Toolbar option using:

 //Removes the 'Show Toolbar' option.
  function as_remove_personal_options( $subject ) {
    $subject = preg_replace( '#<tr class="show-admin-bar">.+?/tr>#s', '', $subject, 1 );
    return $subject;
  }

  function as_profile_subject_start() {
    ob_start( 'as_remove_personal_options' );
  }

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

add_action( 'admin_head-user-edit.php', 'as_profile_subject_start' );
add_action( 'admin_footer-user-edit.php', 'as_profile_subject_end' );
0

You want to hide the checkbox on the profile page based on current_user_can, this appears to work:

function yourprefix_hide_option_show_admin_bar_user_profile_page() { 

    if ( current_user_can( 'manage_product' ) ) {
    ?>
    <style type="text/css">.show-admin-bar { display: none; }</style>
    <?php 
    }

}
add_action( 'admin_print_scripts-profile.php', 'yourprefix_hide_option_show_admin_bar_user_profile_page' );
-1

I have the plugin Theme-My-Login installed and was able to do this by opening wp-content\plugins\theme-my-login\templates\profile-form.php and removing these lines near the top on line 18 or 19:

<table class="tml-form-table">
            <?php if ( apply_filters( 'show_admin_bar', true ) ) : ?>
                <tr class="tml-user-admin-bar-front-wrap">
                    <th><label for="admin_bar_front"><?php _e( 'Toolbar', 'theme-my-login' )?></label></th>
                    <td>
                        <label for="admin_bar_front"><input type="checkbox" name="admin_bar_front" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
                        <?php _e( 'Show Toolbar when viewing site', 'theme-my-login' ); ?></label>
                    </td>
                </tr>
            <?php endif; ?>
            <?php do_action( 'personal_options', $profileuser ); ?>
            </table> 

This most likely will need to be redone every time the plugin is updated.

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.