how to hide the wordpress black top bar from the user after they login?

Posted in: Newspaper
Post count: 42

Hi, I wonder how to hide the WordPress black top bar from users after they logging in? There is no need for users to access to the control panel from the top bar. Thanks!

Post count: 9544

Not part of theme; it’s built in to WP; you can either add a function to disable for everybody; or you control that per user on the ‘edit user’ page for each user. 🙂

Post count: 42

I tried to paste this into functions.php

add_action(‘after_setup_theme’,’remove_admin_bar’);

function remove_admin_bar() {
if (!current_user_can(‘administrator’) && !is_admin()){
show_admin_bar(false);
}
}

It works very well on the mobile theme. But on the desktop, it’s not working at all.

Post count: 42

So sorry I didn’t realize that I need to edit the functions.php for both mobile and desktop. They both work great now! Thanks!

Post count: 9544

Tip… put custom functions into your own plugin, and it survives updates

Post count: 42

How to do that Chris :D?

Post count: 9544

Google ‘how to make your own WordPress plugin’

basically you can just create a plugin per the simple docs on WordPress.org in the ‘codex’ and then you just put the functions in there, upload to plugin folder, activate… ta da.

Really simple.

e.g.,

<?php
/*
Plugin Name: Better Example
Plugin URI: http://wordpress.org/#
Description: Undoing the Madness
Author: Everett's sometimes obnoxious Twin
Version: 0.7
Author URI: http://theonion.com/
*/
function safe_print() {
print " -------- I think I'm getting a clue!";
}
/* End of File */

Viewing 7 posts - 1 through 7 (of 7 total)
The forum ‘Newspaper’ is closed to new topics and replies.