Hide Admin Bar and Toolbar
[resolved] Fatal error: Cannot redeclare get_current_user_role (3 posts)

  1. Cristian Balan
    Posted 2 years ago #

    Fatal error: Cannot redeclare get_current_user_role() (previously declared in /public_html/wp-content/themes/mytheme/.../basic_settings.php:7) in /public_html/wp-content/plugins/global-admin-bar-hide-or-remove/global-admin-bar-hide-or-remove.php on line 78

    I can do something?


  2. Don Fischer
    Posted 2 years ago #

    hi ovib,
    Not sure if you figured this out yet, but it looks like the plugin has a function name that is the same as one you have in your theme.

    Since it is not a good idea to modify the plugin file, you could wrap your function in the themes basic_settings.php file (as it says on line 7) in a !function_exists check, like so (as long as it returns the role of the current user like the one in the plugin):

       function get_current_user_role(){
        // ... blah, blah, blah function code, etc.

    Or, if you don't want to do that, you could just turn off the toolbar from your functions.php file and get rid of the plugin all together.

    To do that, put this in your functions.php file (after the opening <?php tag):

    add_filter( 'show_admin_bar', 'my_global_hide_admin_bar' );
    function my_global_hide_admin_bar($showvar) {
            //$showvar contains the current status.
    	global $show_admin_bar;
    	$show_admin_bar = false; // we set so it works globally
    	return false; //return false for the check so it stays off

    Turning off the toolbar is actually a very simple thing (not sure why WordPress does not let you globally turn it on or off anyway). Most of the plugin overhead is for the options settings - so if you just want it off on the front end, that will turn it off. (remember, you can't turn it off in the back-end, as WordPress does not give you that option).

    Warm regards,

  3. Cristian Balan
    Posted 2 years ago #

    Hi prophecy2040,
    thanks for your reply.

    In meantime I use this in my functions.php file and work fine:

    add_action('after_setup_theme', 'remove_admin_bar');
    function remove_admin_bar() {
    if (!current_user_can('administrator') && !is_admin()) {

    I found it here:

    Thanks however for your time.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Hide Admin Bar and Toolbar
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.