Skip to content

Instantly share code, notes, and snippets.

@mustardBees mustardBees/functions.php
Last active Feb 3, 2016

Embed
What would you like to do?
Show the WordPress toolbar by default
<?php
/**
* Show the toolbar by default
*
* We only want to set this preference once per user so we save a flag which is
* checked before modifying their user settings.
*
* @author iWeb
* @link https://goo.gl/z384Uj
*/
function iweb_show_toolbar() {
if ( in_array( $GLOBALS['pagenow'], array( 'post.php', 'post-new.php' ) ) ) {
$user_id = get_current_user_id();
// This is a one time deal, bail if the user has already had their default set
if ( get_user_meta( $user_id, 'iweb_show_toolbar', true ) ) {
return;
}
set_user_setting( 'hidetb', '1' );
update_user_meta( $user_id, 'iweb_show_toolbar', true );
}
}
add_filter( 'admin_init', 'iweb_show_toolbar' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.