1. Home
  2. Knowledge Base
  3. WC Vendors Memberships
  4. How To
  5. How to Exclude a Plan from the Signup Page?
  1. Home
  2. Knowledge Base
  3. WC Vendors Memberships
  4. How to Exclude a Plan from the Signup Page?

How to Exclude a Plan from the Signup Page?

There might be a time when you need to exclude a membership plan from displaying on the signup page. The following snippet will allow you to exclude one or more membership products from the list. 

The following code would go in your themes functions.php.

function hide_specific_membership_plan( $query_args ) {
    $user_id = get_current_user_id();
    if ( ! $user_id ) {
        return;
    }
    $user_data  = get_userdata( $user_id );
    $user_roles = $user_data->roles;
    if ( in_array( 'subscriber', $user_roles ) ) {
        //Post ids that you want to hide
        $exclude_posts = array( 1250 );
        $query_args['post__not_in'] =  $exclude_posts;
    }
    return $query_args;
}
add_filter( 'wcv_membership_signup_product_query_args', 'hide_specific_membership_plan', 10, 1 );
Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support