Does Membership2 have conditional tags that can be used

Does Membership2 have conditional tags that can be used with other plugins and code throughout the WP site? I have portions of the site that I would like finer access control and don't integrate with Membership2 and I thought conditionals would be great.

For example: Standard WP conditional is_user_logged_in()

Is there a Membership2 conditional like is_user_member_of(id#) ?

  • Adam Czajczyk

    Hello Preston,

    I hope you're well today and thank you for your question!

    Our Membership 2 Pro plugin features a nice API that would let you create custom integration with other plugins as well as build custom functions for your theme. You can find out more about it right in your site's dashboard by going to

    "Membership 2 -> Help -> API Docs" page.

    There is for example "has_membership($membership_id)" function that checks current user against membership. If you provide "$membership_id" value (which is an ID of selected membership) it will return true if user is a member of that membership and false if not. If membership ID is not specified it will return true if user is a member of any membership and false if not. For example

    $membership_id = 21;
    if (has_membership($membership_id))  {
    echo "You're a member of membership of ID: 21";
    }
    else {
    echo "You're not a member of membership of ID: 21";
    }

    or

    if (has_membership()) {
    echo "Hello Member!";
    }
    else {
    echo "You're not a member of our community!";
    }

    For further reading please take a look at aforementioned docs inside your site's dashboard.

    I hope that helps!

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.