• Resolved Syxguns

    (@syxguns)


    I am working on the final touches to get my site live. I was wondering why during testing as a user the Admin Bar was showing. I use a simple mu-plugin that looks like this:

    function hide_admin_bar($show)
    {
    
        if (current_user_can('author') || current_user_can('subscriber') || current_user_can('prpro_role_1') || current_user_can('member') || current_user_can('contributor')) :
            return false;
        endif;
    
        return $show;
    }
    add_filter('show_admin_bar', 'hide_admin_bar');

    Since that was not working I changed the code to this:

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

    Still not working so I went straight for the good ‘ole codex code:

    if (!current_user_can('manage_options')) {
        show_admin_bar(false);
    }
    

    Still no glory!!! I then installed a plugin called “Hide Admin Bars Base On User Roles” and that didn’t work either.

    To quadruple check me I opened two other browsers to ensure that it had nothing to do with history or cache. Still, I have an Admin Bar, so I’m thinking there is something wrong with the latest version of WP v5.6.2.

    Anyone else experiencing the same issue?

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator bcworkz

    (@bcworkz)

    Does the “Show Toolbar when viewing site” profile option work as expected? Why not let users choose instead of forcing it?

    Anyway, if the option works, there ought to be a way to have appear as always unchecked. I can dig deeper if the option at least works.

    Thread Starter Syxguns

    (@syxguns)

    No, turning that feature off does not work either. I’ll try to do a quick WP update to see if that fixes anything.

    There is not a problem with having the Admin Bar visible, but I try to place everything on the front-end for the site member. They do not need to see the bar when there is not anything for them really in the back-end. I think of it as a distraction.

    I’ll update if I find a work-around.

    Edit: doing an update of WordPress didn’t solve the issue. The plugin I installed doesn’t work, nor does any of the code. I wonder if I have a plugin conflict. That will be the next thing I check.

    • This reply was modified 4 years, 3 months ago by Syxguns.
    Moderator bcworkz

    (@bcworkz)

    Yes, a plugin or theme conflict is highly suspected. If all else fails, you could probably override the CSS that shows it so it’s at least hidden even if the HTML is still present.

    Thread Starter Syxguns

    (@syxguns)

    I might have found the issue. A plugin called The Events Calendar is causing a big headache right now. https://wordpress.org/plugins/the-events-calendar/

    Notice: Undefined index: the-events-calendar/common/vendor/freemius in /xxx/xxx/public_html/wp-content/plugins/front-end-pm/freemius/start.php on line 184

    Notice: Trying to get property 'plugin_path' of non-object in /xxx/xxx/public_html/wp-content/plugins/front-end-pm/freemius/start.php on line 189

    Notice: Undefined index: the-events-calendar/common/vendor/freemius in /xxx/xxx/public_html/wp-content/plugins/front-end-pm/freemius/start.php on line 277

    Why is The Events Calendar conflicting with Front-End-PM? I need Front-End-PM so I’ve got to try and figure this out. I don’t want to restore a backup as I’ve had too many changes to the site in the last few days.

    Maybe after I get this sorted my Admin Bar will work again.

    I’ll document and let the plugin authors know of the issue.

    Thread Starter Syxguns

    (@syxguns)

    The above was a pretty quick fix. I had to remove Front-End PM because I could not find any entries in the database for The Events Calendar Plugin. I hadn’t created any events as the site is in development, so maybe that is why?

    Since I had already removed the events plugin but was still having an issue. I searched the database to track down the problem. I could not find any entries for the plugin, but the error was there. I downloaded FEPM and overwrote the files in the plugins directory. That still didn’t clear the error.

    I removed FEPM from the site, removed all database entries of FEPM, then reinstalled the plugin, so it could repopulate the database. Now the error is gone.

    The Original Issue
    That did not fix the original issue though, I’m troubleshooting a few other things. I went ahead and removed the plugin that hides the bar, and placed my mu-plugin back. I will test again soon to see if I can find another possibility.

    @bcworkz – I am able to hide the visibility of the admin bar with CSS. I may end up doing that in the end, but I use the bar as an Admin, so would like to keep it, if I can. I can work without the bar, it’s just not as convenient.

    • This reply was modified 4 years, 3 months ago by Syxguns.
    Thread Starter Syxguns

    (@syxguns)

    Found it!
    It was a pro plugin called RegistrationMagic. I’ll contact them and let them know of the issue that needs to be resolved.

    In the meantime, I used a great plugin called Advanced Access Manager by Vasyl Martyniuk. You have the ability to remove everything from the Admin Bar with this plugin. It just leaves a black bar at the top. On the left of the black bar is the website name, and the right of the bar only has the magnifying glass. It is almost not noticeable.

    At least I found out that it was a plugin issue. I need that plugin, so at least I found a temporary solution until it is updated.

    Thanks for listening to me rant! LOL, trying to complete a design and something is not working the way you want! πŸ™

    Moderator bcworkz

    (@bcworkz)

    Sorry to hear of all the trouble you’ve been having. I can only imagine the frustration that would cause. I’m glad you found a suitable solution for the admin bar.

    FWIW, we could have conditionally hidden or not hidden with CSS based on user role. Simply hiding isn’t the best solution anyway.

    Thread Starter Syxguns

    (@syxguns)

    @bcworkz

    FWIW, we could have conditionally hidden or not hidden with CSS based on user role. Simply hiding isn’t the best solution anyway.

    I can hide with CSS like this:

    #wpadminbar {
       display: none;
    }

    I’m not certain how to black conditionally with CSS. I am familiar with these conditional statements:

    I would love to learn to apply a conditional statement for users in CSS.

    • This reply was modified 4 years, 3 months ago by Syxguns.
    Moderator bcworkz

    (@bcworkz)

    You are right, CSS has no knowledge of user role. What you do conditionally is manage whether the relevant CSS is sent to the browser at all. You could conditionally enqueue a CSS file. If you’d rather not have an entire file just for this purpose, you could instead conditionally output a style block with the relevant CSS from the “admin_print_styles” action hook. Add your callback with a large priority argument so it’s the last style output.

    Thread Starter Syxguns

    (@syxguns)

    @bcworkz
    That is a project for another day! The force is not yet strong for this padawan! πŸ™‚

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Admin Bar or Top Bar is not hiding!’ is closed to new replies.