• Resolved emmytechs

    (@emmytechs)


    Kindly assist with a hook or snippet that can return true or false if a user has a membership plan or not. I’ve tried some snippet but none works

    $author_id = get_post_field( ‘post_author’, $post_id );
    $plan_id = wps_membership_get_meta_data( $post_id, ‘plan_obj’, true );

        if ( is_array( $plan_id ) && ! empty( $plan_id ) ) {
    $plan_id = $plan_id['ID'];
    } else {
    $plan_id = 0;
    }
    $withdrawal_status = wps_membership_get_meta_data( $post_id, 'member_status', true );

    if ( 'complete' === $withdrawal_status ) {

    Kindly assist on this. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter emmytechs

    (@emmytechs)

    Wrote this snippet instead to solve the issue

    function user_has_membership(){

        $user_id = get_current_user_id();
        $current_memberships = get_user_meta( $user_id, 'mfw_membership_id', true );
    
        if ( ! empty( $current_memberships ) && is_array( $current_memberships ) ) {
            foreach ( $current_memberships as $key => $membership_id ) {
                $member_status = wps_membership_get_meta_data( $membership_id, 'member_status', true );
                if ( ! empty( $member_status ) && 'complete' == $member_status) {
                    return true;
                }
            }
        }
            return false;
     }

    Kindly take a look. Thanks.

    • This reply was modified 4 months, 2 weeks ago by emmytechs.
    Plugin Author WP Swings

    (@wpswings)

    Hello,

    It seems the issue is solved now, if not please tell me so that we can help you

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.