Skip to content

Commit

Permalink
Merge pull request #53 from WebDevStudios/show-admin-bar
Browse files Browse the repository at this point in the history
Allow designers to hide/show wp admin bar using parameter w/out logging out.
  • Loading branch information
gregrickaby committed Jun 28, 2015
2 parents fc482c0 + ba0356a commit 0f0fb21
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion inc/extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,21 @@ function _s_render_title() {
}
add_action( 'wp_head', '_s_render_title' );

endif;
endif;

/**
* Allows an administrator to set the logged in user.
*
* Setting to false will emulate a logged out user.
*
* @return void
*/
function _s_wp_set_current_user() {
if ( ! is_user_logged_in() || ! isset ( $_GET['wp_set_current_user'] ) || ! current_user_can( 'create_users' ) ) {
return;
}

wp_set_current_user( is_numeric( $_GET['wp_set_current_user'] ) ? absint( $_GET['wp_set_current_user'] ) : ( 'true' == $_GET['wp_set_current_user'] ? true : false ) );
}

add_action( 'init', '_s_wp_set_current_user' );

0 comments on commit 0f0fb21

Please sign in to comment.