• Resolved wbc59

    (@wbc59)


    Hi,

    I am using membership with a badminton court booking feature.
    I need to check if the partner (second player) is a member of the same membership than the current user or if his membership is not expired (same season or in an active season).
    I have looked on usermeta but it seems to be hard to decode and i haven’t seen à function like is_membership_active() ?
    How could i do this ?

    Thanks in advance,

    Regards

    The page I need help with: [log in to see the link]

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

    (@wpmudev-support7)

    Hi @wbc59,

    As I understand, once the user reserve the court, they will be able to select or add other existing user, so you need to check if the user has an active subscription and it’s in the same subscription as the user scheduling the court?

    If that’s the case, could you please try the following code (should return false if there is no subscription):

    $api = ms_api();
    $subscribed = $api->get_subscription( $user_id, $membership_id );

    Hope this helps,

    Jorge

    Thread Starter wbc59

    (@wbc59)

    Hi Jorge,

    You have fully understood my need, I will try it as soon as possible.

    Thanks

    Thread Starter wbc59

    (@wbc59)

    It works fine, thanks !

    But, I had to put the membership_id in hard in the code.
    Do you think it’s possible to retreive it from the first user or form the current page ?

    Regards.

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @wbc59

    I trust you’re doing well!

    The following code will retrieve the user’s membership ID

    $member = MS_Model_Member::get_current_member();
    
    foreach ( $member->subscriptions as $subscription ) {
        $membership = $subscription->get_membership();
    }

    And also $member->get_membership_ids()

    Please note, if the Multiple Memberships add-on is active the code needs to handle multiple memberships.

    Hope this helps!

    Cheers,
    Nastia

    Thread Starter wbc59

    (@wbc59)

    Hello Nastia,
    Thank you so much !
    I wish you the best.

    Cheers,
    Nicolas

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘check access other member’ is closed to new replies.