Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Don Fischer

    (@prophecy2040)

    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):

    if(!function_exists('get_current_user_role')){
       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,
    Don

    Thread Starter OviLiz

    (@ovib)

    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()) {
      show_admin_bar(false);
    }
    }

    I found it here:
    https://www.wpbeginner.com/wp-tutorials/how-to-disable-wordpress-admin-bar-for-all-users-except-administrators/

    Thanks however for your time.
    Ovi

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error: Cannot redeclare get_current_user_role’ is closed to new replies.