[wp-trac] [WordPress Trac] #33165: Remove option to not show toolbar when viewing site
WordPress Trac
noreply at wordpress.org
Sat Sep 19 03:33:57 UTC 2015
#33165: Remove option to not show toolbar when viewing site
-------------------------------------+--------------------------
Reporter: celloexpressions | Owner: morganestes
Type: enhancement | Status: assigned
Priority: normal | Milestone: 4.4
Component: Toolbar | Version: 3.0.5
Severity: normal | Resolution:
Keywords: has-patch needs-refresh | Focuses: ui
-------------------------------------+--------------------------
Changes (by morganestes):
* owner: => morganestes
* status: new => assigned
Comment:
Replying to [comment:10 wonderboymusic]:
> what happens if the user has toggled it off, we drop in this change, and
then they want to activate the toolbar again?
Even though the UI is removed, the underlying functionality still exists.
A couple of working options I came up with:
1. re-activate for a specific user by updating the setting:
{{{
update_user_option( $user_id, 'show_admin_bar_front', 'true' );
}}}
2. Use a filter to show the admin bar for a user, regardless of the user's
setting:
{{{
add_action('init', function() {
if ( get_current_user_id() === $user_id ) {
add_filter( 'show_admin_bar', '__return_true' );
}
});
}}}
The first option is better for a single user, since it's only set once and
is checked already by `_get_admin_bar_pref()`. The filter option is best
if you don't know the user ID, if you want to show the toolbar based on a
different conditional check, or if you want to skip conditionals and and
force it on/off for all registered users.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33165#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list