• Resolved Leinad4Mind

    (@leinad4mind)


    Hi there, when the users expire they are not being moved to the group I selected:

    /*
    	When users cancel (are changed to membership level 0) we give them another "cancelled" level. 
    	Can be used to downgrade someone to a free level when they cancel.
    	Will allow members to the "cancel level" to cancel from that though.
    */
    function my_pmpro_after_change_membership_level($level_id, $user_id)
    {
    	//set this to the id of the level you want to give members when they cancel
    	$cancel_level_id = 5;
    	
    	//are they cancelling?
    	if($level_id == 0)
    	{
    		//check if they are cancelling from level $cancel_level_id
    		global $wpdb;
    		$last_level_id = $wpdb->get_var("SELECT membership_id FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user_id . "' ORDER BY id DESC");
    		if($last_level_id == $cancel_level_id)
    			return;	//let them cancel
    		
    		//otherwise give them level $cancel_level_id instead
    		pmpro_changeMembershipLevel($cancel_level_id, $user_id);
    	}
    }
    add_action("pmpro_after_change_membership_level", "my_pmpro_after_change_membership_level", 10, 2);
    

    Why it doesn’t change? Why the users goes to the expired level? Instead of the one I told (level 5) ?

    • This topic was modified 8 years, 5 months ago by Leinad4Mind.
Viewing 4 replies - 16 through 19 (of 19 total)
Viewing 4 replies - 16 through 19 (of 19 total)

The topic ‘Expiration Problem’ is closed to new replies.