Disable trail Membership 2 Pro

If a user has signup using paid membership and then after the someday user needs to change his membership and is it possible to disable the trail option once a member had a paid subscription already.

  • Panos

    Hi Jing ,

    This is not supported out of the box, but it should be possible with the following snippet:

    add_filter( 'ms_model_relationship_is_trial_eligible', function( $eligible, $subscription ) {
    
    	$member = $subscription->get_member();
    
    	if ( $member instanceof MS_Model_Member ){
    
    		$active_memberships = array();
    		$active_status 		= array(
    			MS_Model_Relationship::STATUS_ACTIVE,
    			MS_Model_Relationship::STATUS_TRIAL,
    			//MS_Model_Relationship::STATUS_CANCELED,
    			//MS_Model_Relationship::STATUS_EXPIRED,
    		);
    
    		foreach ( $member->subscriptions as $sub ) {
    			if ( $sub->is_base() ) { continue; }
    			if ( ! in_array( $sub->status, $active_status ) ) { continue; }
    
    			$membership 							= $sub->get_membership();
    			$active_memberships[$membership->id] 	= $membership;
    		}
    
    		if ( count( $active_memberships ) > 0 ) {
    			$eligible = false;
    		}
    
    	}
    
    	return $eligible;
    
    }, 20, 2 );

    Depending on your requirements you may want to un-comment one of both of these lines:

    /MS_Model_Relationship::STATUS_CANCELED,
    //MS_Model_Relationship::STATUS_EXPIRED,

    from the above snippet.

    Hope this helps :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.