• Resolved improve21

    (@improve21)


    I have installed WP-Members. I have also turned off “anyone can register”. During testing, when logged in as a member, I see a black strip at the top of the page which is a wordpress user bar, which I don’t want to appear. There are no options anywhere for turning that off, either in wordpress or in wp-members.

    Looking around for answers I found this page:
    https://www.butlerblog.com/2011/09/23/how-to-disable-the-wordpress-admin-bar/
    suggesting adding some code to the functions.php file:

    If you would like to keep the admin bar for yourself, you just need to add a condition to test to see if the current user is an admin. This example tests if the user has the capability to ‘manage_options’. (If you have a role manager installed and have made changes to the default WP roles, adjust this accordingly.)

    if ( ! current_user_can('manage_options') ) {
        add_filter( 'show_admin_bar', '__return_false' );
    }

    This can be used regardless of whether you are using the WP-Members plugin or not, but if you are using the plugin, this will prevent your subscribers fromhaving the admin bar appear for them when they are logged in

    It sounds like a simple fix, yet I am hesitant in case it doesn’t work as I expect and instead actually bars me from the admin panel, which would make me unable to get into my wordpress admin anymore.

    In the User section, I have set my role as “Administrator”. So in theory, I shouldn’t get blocked from seeing the top bar, however I can’t be certain about the code, as that is not my area of knowledge. It refers to “role manager” and “manage_options”, which doesn’t seem to exist in the admin panel, although I see there are plugins for role managers, yet I am hoping I don’t have to add yet another plugin – unless necessary. I am wondering if setting myself as admin in the users area is enough, and whether the above suggested code would work in the functions.php file to stop logged-in members from seeing the bar, except for me as admin of course.

    Otherwise, I wonder if there is another idea or workaround?

    https://www.ads-software.com/plugins/wp-members/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    The show_admin_bar filter only affects whether the admin/tool bar is displayed or not. It does not affect access to the dashboard, so you don’t need to worry about locking yourself out.

    Thread Starter improve21

    (@improve21)

    Ok, that gave me more confidence to add it.
    However it didn’t work.

    I have no “role manager” plugin. There is only the User section where I see those who have joined, both via wp-members and also myself as admin via wordpress. They all seem to go in that section.

    I joined via wp-members as a test user, so I used that login to test whether the code worked. And I have a couple of other test user accounts. All my test user accounts (including wp-members) are assigned as “subscriber”, and I as administrator am listed as admin.

    I wonder if there is a different code to use in the “if” section?

    Plugin Author Chad Butler

    (@cbutlerjr)

    However it didn’t work.

    Since the snippet there is a WordPress filter, there’s no reason it would not work (i.e. nothing in it actually has anything to do with the plugin – this is a WP filter and the function calls in it are WP functions).

    The snippet should go in your theme’s functions.php file.

    The discussion of a role editor is only related to the capability indicated in current_user_can(). If you are not using a role manager, then ‘manage_options’ would only be an admin.

    Thread Starter improve21

    (@improve21)

    Well, that was a bad experiment!

    I discovered I accidentally added it to the theme’s css file instead of functions.php file. So, removed it from there abd added the code to the right file. See image:

    Now, everywhere I look is a blank screen.

    The only thing I can view is the functions.php screen editor, only because I hit the back button, but everywhere else, is blank. Even on different browsers.

    I tried taking the code back off and saving, but still I get a white screen ??

    Now I thought I would save an image to show you what I put in the functions file and uploaded it, but I can’t even see the image when I call it up on the browser.

    So, what now?

    Thread Starter improve21

    (@improve21)

    Never mind, I found an original functions.php file and restored it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to disable the WordPress admin bar for logged-in users, except admin’ is closed to new replies.