Remove Plugin’s Toolbar Items for a Certain User

You can disable the Toolbar Extra items on the Toolbar globally for a certain user.

The use case could be that there is another administrator user on the site who shouldn’t see the items of Toolbar Extras. You only need to know the ID of that user:

/**
 * Plugin: Toolbar Extras:
 *    Remove Items for user ID 2 (admin role)
 */
if ( 2 === get_current_user_id() ) {
  define( 'TBEX_DISPLAY', FALSE );
}

Make sure you get the correct user ID, in the example above it is 2, and make sure this an administrator actually.

You can also do this for more than one user, like so:

/**
 * Plugin: Toolbar Extras:
 *    Remove Items for user IDs 2, 7 and 10 (admin roles)
 */
if ( in_array( get_current_user_id(), array( 2, 7, 10 ) ) ) {
  define( 'TBEX_DISPLAY', FALSE );
}

Just replace the numbers in the above example with the actual user IDs – and add more IDs, separated by comma.