How do I hide the sidebar form non-members?

Hi, I’ve added protection to my site, but the sidebar and all its content is still showing. How do i also hide the sidebar from non-members?

  • Bojan Radonic
    • CCO / Deputy COO

    Hey there Carina,

    How are you doing today?

    Membership 2 doesn’t offer this type of functionality out of a box so we can’t completely hide the sidebar for visitors.

    However, Membership 2 does have specific classes in body element that are added based on membership of a user that is on the page so we can use those to hide anything, including sidebar, on the page based on user membership with some custom CSS.

    So first off can you please grant me temporary admin access to your site so I can take a look? You’ll find more information on how to do that by following this link: https://wpmudev.com/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Aside from that I’ll need a little bit more information, which sidebar do you want removed, is this sidebar on specific page or sidebars across your site? Or perhaps you’re looking to hide only specific widget in sidebar? Please let me know and potentially include screenshot of what specifically you want to remove and I’ll be more then happy to help with that :slight_smile:

    Looking forward for your reply!

    Cheers,

    Bojan

  • Bojan Radonic
    • CCO / Deputy COO

    Hey Carina,

    I’ve checked your site and hopefully managed to do this for you cause I had few things I wasn’t sure about so:

    1. when you say non-members you’re referring to guests/site visitors, correct?

    2. in the current setup when visitor attempts to see your home page he gets redirected to Protected Content page so the changes I’ve applied are removing sidebar on that page cause this is what visitor sees on your front page, is this what you’re looking for?

    I assumed above is what you want so correct me if I’m wrong and I’ll adjust the CSS code :slight_smile:

    I couldn’t find any custom CSS tabs so I’ve installed Simple Custom CSS plugin on your site and added the code to Appearance -> Custom CSS, this is what I’ve added:

    .page-id-23.ms-guest aside.x-sidebar.nano.has-scrollbar {
    display: none;
    }

    .sfm-no-mobile.sfm-pos-left body.ms-guest.page-id-23, .sfm-no-mobile.sfm-pos-left #wpadminbar {
    padding-right: 0;
    }

    First part removes the sidebar on Protected Content page for visitors only (ones that have Guest membership applied), second part of code expands the content to fill the place where sidebar was for same users (I again assumed this is what you’ve wanted, correct me if I’m wrong).

    This is how Protected Content page looks like now for visitors:

    [attachments are only viewable by logged-in members]

    Please let me know about the above, hope this helps :slight_smile:

    Cheers,

    Bojan

  • Bojan Radonic
    • CCO / Deputy COO

    Hey again Carina,

    Still worked on my end but after sending link to your site to some of my colleagues some of them still saw the sidebar, the issue should be related to .has-scrollbar class that I’ve unintentionally copied from the inspector, I’ve modified the code and removed that so it should work now, apologies for that :slight_frown:

    Let me know if it is good now please :slight_smile:

    Cheers,

    Bojan