skip to Main Content

Can’t really get to the bottom of this issue. I’m running a WordPress news website on a Debian WHM / Cpanel server. The server runs nginx and I am using redis for the website’s cache. I am also using the nginx helper plugin for WordPress.

The problem is that the WordPress Admin bar keeps appearing to visitors, even visitors who never logged in on the website. They can’t really go inside the site’s admin panel as if they click on a link in the WordPress Admin bar they are being asked for a username and password but this is still disturbing.

Any one of you experienced this before and know of a way to fix it ?

2

Answers


  1. for display admin bar to all users you have to install this plugin
    Try this link

    and also try this code

    function my_function_admin_bar($content) {
        return false;     
     }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');
    

    i have not check this code yet but i used This-Link for reference purpose.

    Login or Signup to reply.
  2. You are caching html version of the site. I have been facing this issue for so long. This can be so frustrating, I know.

    Problem: When site cache is cleared and you are logged in as admin so the caching system will cache the page from a logged in user/admin. Which means they will cache the admin bar as well.

    Solution: There are some ways you can try but the best possible way it to add this code function.php to hide admin bar and only show it on pages where needed with adding a string show=true to URL E.g. https://www.example.com/?show

    function ba_hide_admin_bar() {
      if ($_GET['showAB'] || $_GET['show'] || $_GET['ab'] || $_GET['AB']) {
        show_admin_bar(true);
        return;
      } 
      show_admin_bar(false);
    }
    add_action( 'init', 'ba_hide_admin_bar' );
    

    Or For short Install this plugin

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search