ms_has_membership seems not be working

Hi,

I’m trying to show the buy button in a woocommerce just if the user is a membership one. I’m using ms_has_membership function but it seems not to be working.

Is this the correct function to do that?

  • Predrag Dubajic
    • Support

    Hey @juanma_evaristo,

    Hope you’re doing well today :slight_smile:

    Could you provide us with the entire code you are using so we can see what might be wrong in there, if there’s a lot of code you can use pastebin.com and provide us with URL.

    For making a condition your code should look something like this:

    $api = ms_api();
    $member = $api->get_current_member();

    $membership_id = 100; // harcoded or use line below.
    $membership_id = $api->get_membership_id( 'premium' ); // fetch by membership name.
    if ( $member->has_membership( $membership_id ) ) {
    // ... do your stuff.
    }

    Best regards,

    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.