1. Home
  2. Exclude a plan from the signup page

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 );

filters

Updated on September 17, 2021

Was this article helpful?