Check to see if user is member or non-member

I am using the Membership plugin on my site. I am also using Formidable pro to create forms on my site. What I want to do in one of my forms is check to see if the user that is logged in is a member or non-member. I have set up 3 Access Levels: Free, Club Member and Race Team Member.

How would I check to see if the logged in user is a paid member (ie. Club Member or Race Team Member) or a un paid member (non-member / Free)? Also in my check I want to say that they aren’t a member if they aren’t logged in.

How would I do this?

Thanks!

  • Jonathan
    • The Incredible Code Injector

    @mccawphoto,

    You’re in luck. Barry from the beginning was so kind as to create some functions for that exact purpose.

    You will find a whole bunch in the /membershipincludes/includes/functions.php file

    Here are a few

    current_user_is_member()
    current_user_has_subscription()
    current_user_on_level($level_id)
    current_user_on_subscription($sub_id)

    So you will implement something like this…

    //Checks if current_user_on_level($level_id) and returns true or false
    if ( current_user_on_level($level_id) ) {
    // TRUE: Yes He Is so put your member only code here
    } else {
    // FALSE: No He Isn't so Put you non member stuff here
    }

    Hope that gets you going :wink:

  • mccawphoto
    • The Incredible Code Injector

    @jonathan,

    Thanks!

    One question. If I want to check if a member is level_id 2 or 3 than would I put something like:

    if ( current_user_on_level(array(2,3)) ) {
    // TRUE: Yes He Is so put your member only code here
    } else {
    // FALSE: No He Isn't so Put you non member stuff here
    }

    Thanks!

  • Jonathan
    • The Incredible Code Injector

    No, that won’t work…

    This is probably you best option, using subscription plans instead of levels:

    if( current_user_on_subscription(2) ) {
    // Member on level two subscription plan
    } else if ( current_user_on_subscription(3) ) {
    // Member on level 3 subscription plan
    } else {
    // Member on free plan that is if there are only 3 subscription plans free, club member and race team
    }

    You could also use

    current_user_is_member()
    current_user_has_subscription()

    This checks that they are infact all paid up but only if your free user is a stranger meaning they are not an actual registered user who is active. registered inactive user will return false, which is good.

    If one of your subscription plans is a free one then is_member and has_subscription won’t work for you then you had best use code above.

    I could be mistaken though, I appologize, it is very very late here my me and my old brain is suffering a little lol, could a staff member confirm?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.