Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#30428 closed defect (bug) (invalid)

Admin bar cannot be turn off for users with administrator's role

Reported by: cypves's profile Cypves Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0.1
Component: Toolbar Keywords:
Focuses: ui, administration Cc:

Description

There is a filter "show_admin_bar" which determinate whether the admin bar is shown or not. But for users with administrator's roles there isn't way how the admin bar disable because of a condition in front of line where the filter is applying.

The following function is from admin-bar.php.

/**
 * Determine whether the admin bar should be showing.
 *
 * @since 3.1.0
 *
 * @return bool Whether the admin bar should be showing.
 */
function is_admin_bar_showing() {
	global $show_admin_bar, $pagenow;

	// For all these types of requests, we never want an admin bar.
	if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') )
		return false;

	// Integrated into the admin.
	if ( is_admin() )              <---------------------------------------
        return true;

	if ( ! isset( $show_admin_bar ) ) {
		if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) {
			$show_admin_bar = false;
		} else {
			$show_admin_bar = _get_admin_bar_pref();
		}
	}

	/**
	 * Filter whether to show the admin bar.
	 *
	 * Returning false to this hook is the recommended way to hide the admin bar.
	 * The user's display preference is used for logged in users.
	 *
	 * @since 3.1.0
	 *
	 * @param bool $show_admin_bar Whether the admin bar should be shown. Default false.
	 */
	$show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar );

	return $show_admin_bar;
}

I recommend that condition give away.

Change History (4)

#1 @Cypves
10 years ago

  • Focuses ui added

#2 @joedolson
10 years ago

  • Focuses accessibility removed

#3 @SergeyBiryukov
10 years ago

  • Component changed from Administration to Toolbar

is_admin() is a check for whether we are in the admin area, not whether the current user is an admin.

Toolbar cannot be disabled in the admin area regardless of the user role, that's by design, see #19685.

#4 @chriscct7
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Invalid per comment:3

Note: See TracTickets for help on using tickets.