Access levels in theme files

Is there a way to integrate access levels in a custom theme file rather than using the shortcodes or the WP do_shortcode? I couldn't find a direct php integration in the manual or any place else...then again, I may have skipped over it or not looked in the right place.

  • aecnu
    • WP Unicorn

    Greetings nwtech,

    Thank you for the great question.

    Is there a way to integrate access levels in a custom theme file rather than using the shortcodes or the WP do_shortcode?

    Not that I am aware of but then again I certainly do not know everything :smiley:

    Therefore I will see if I can get the lead developer in here with his invaluable insight into this plugin for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Barry
    • DEV MAN’s Mascot

    You can use the functions the plugin has for this very purpose - have a look in the file membershipincludes/includes/functions.php for some of the functions you can use such as:

    current_user_is_member

    current_user_has_subscription

    current_user_on_subscription

    current_user_on_level

    You can also get the current users record using:
    $member = current_member();

    And then use that object to check things like:

    $member->is_member(), etc...

  • NWTD
    • The Incredible Code Injector

    Thanks for the help Barry. I'm a PHP novice, so I'm learning as I go. Using the info you provided, can you guide me to how the code would look? All I'm trying to do is hide some information from visitors or those that do not have a subscription.

    TIA

  • Barry
    • DEV MAN’s Mascot

    You'd use them in an if statement to wrap content e.g.

    if(current_user_has_subscription()) {
    // If the user is a member and has a subscription
    echo "hello member";
    } else {
    // If the user doesn't have a subscription
    echo "Why not sign up";
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.