• Hi,
    I am trying figure out how to use a function such as has_membership() to do php if/else statements in my theme template pages.

    For example, certain dropdown links will only be visible to members with membership id 1, so in my header.php page I would do —

    <?php if (has_membership(1)) { ?>
    //code..
    <?php } else { ?>
    //more code...
    <?php } ?>

    https://www.ads-software.com/plugins/membership/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Bojan Radonic – WPMU DEV Support

    (@wpmudev-support4)

    Hey there MYGM,

    How are you doing today?

    Since you’re mentioning header.php I’m assuming you want to hide specific menu links for members in different membership levels.

    If that is the case you should be able to do that with menu item protection. To set those protection rules please go to Membership 2 -> Protection Rules -> Menu Items.

    Hope this helps ??

    Cheers,
    Bojan

    Thread Starter MYGM

    (@mygm)

    Hi thanks for the response however my links are custom coded and I need more control than that within my theme templates. Is there a code snippet you can provide?

    Plugin Author Bojan Radonic – WPMU DEV Support

    (@wpmudev-support4)

    Hey again MYGM,

    This is pretty close on what you need to do, you just missed a proper function name, please try using the following:

    <?php if ( ms_has_membership(190) ) { ?>
    //code..
    <?php } else { ?>
    //more code...
    <?php } ?>

    190 is the membership ID.

    Hope this helps ??

    Cheers,
    Bojan

    Thread Starter MYGM

    (@mygm)

    Thanks that seems to be it. However the membership id, is that a unique number per user? Cause I was looking to use numbers that correlate to the actual membership levels?

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @mygm

    That would be the membership id not the userid, to get the membership level ID, simply hover over the edit membership level in the membership levels list and in the status bar you will see the membership_id.

    Hope this helps.

    Have a great day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘if has_membership() php function’ is closed to new replies.