Hide menu and header items from members

I was wondering if there is a built in way to do this with Membership 2 or if I can use jQuery or something to get this to work?

<script type="text/javascript">
If $(document).ready(function(){
$(#buttonID).css("display", "none");

I would prefer to do this either through the plugin or with another plugin rather than writing code.

  • Nastia

    Hello qualityeye

    Welcome to WPMU DEV Community!

    With Advanced menu protection add-on menus can be protected; the add-on protects single menu-items, replaces whole menus or overwrite the content of the menu. To activate it please go to the Membership 2 > Add-ons, please see the attached screenshot:
    [image pos="0"]

    Click on details to select how you wish to protect the menus. To set protection Rules, go to Membership 2 > Protection Rules > Menu Items and modify access.

    As for the hiding elements in the Header, if it is added as a content, you can hide it with a shortcode:

    [ms-protect-content id="1"] Only members of membership-1 can see this![/ms-protect-content]

    Full list of shortcodes can be found in Membership 2 > Help > Shortcodes.

    Please note, the plugins' protection rules are mostly showing content to the members of a membership, then hiding it from there. In Protection Rules you can set to show specific content to a specific membership.

    Hope this helps!

    Kind regards,

  • Oguz

    Hey qualityeye ,

    Hope you're well.

    There is no ready to use JS variable for that. It's not impossible but Nastia's explanation is much easier and ready to use solution. If you want to solve it via CSS codes jQuery is not a good option I think, you can use only CSS for that. Membership 2 plugin adds class to the body with the ID of membership like if membership ID 10 there will be ms-10 class. So you can add CSS code like that;
    .ms-10 #buttonID{display:none;}

    That will be more performance purpose approach than jQuery way.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.