Remove logout bar when not logged in
-
Hi
1. In order to display the WP admin bar as standard at the top of our site, I have used this code in functions.php which after editing the css for our colours, looks good and just has a simple login link.
// always show admin bar
function pjw_login_adminbar( $wp_admin_bar) {
if ( !is_user_logged_in() )
$wp_admin_bar->add_menu( array( ‘title’ => __( ‘Log In’ ), ‘href’ => wp_login_url() ) );
}
add_action( ‘admin_bar_menu’, ‘pjw_login_adminbar’ );
add_filter( ‘show_admin_bar’, ‘__return_true’ , 1000 );2. As this is just a commercial site and we do not want users to access the default wp user account page – we’re using Woocommerce – we then also coded out ‘my-account’ from the bar.
add_action( ‘admin_bar_menu’, ‘remove_my_account’, 999 );
function remove_my_account( $wp_admin_bar ) {
$wp_admin_bar->remove_node( ‘my-account’ );
}3. So far, so good but needing a logout function, then downloaded One-Click-Logout, edited css to match and it looks & works great, but ….
a. First main issue seems to be that the bar actually sits on top of the default wp admin bar we coded in as above – even after the user has logged out – so that standard bar is no longer visible and we lose the login function ?
b. Second smaller issue is that it would be good if we can also amend the background colour of just the ‘logout’ box itself to give it more impact on the bar – couldn’t seem to identify the right css code ?
So hope you can help with a work round on this, perhaps to code out your bar when logged out?
Thanks and look forward to any comments.
- The topic ‘Remove logout bar when not logged in’ is closed to new replies.