Does this plugin have the ability to keep invite codes for

Hello,

Does this plugin have the ability to keep invite codes for different subscription plans? I have two different membership plans that need to work differently. One plan needs to keep its codes. The other plan needs them removed after theyve been used.

I dont see an option to make that happen, but i feel like it does some how, I just dont see it.

Im sorry if this is a double post. my post before disappeared and I cant find it at all.

Thank you.

  • Ash

    Hello @odotjdot

    I hope you are well today and thanks for asking the question.

    No, this is not possible out of the box. But it's maybe possible with some custom code, I am not sure though.

    I am tagging an available developer from second level support line in this thread for his valuable opinion on this issue. Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    Cheers
    Ash

  • Hoang Ngo

    Hi @odotjdot,

    I hope you are well today.

    Look like we need to add some extra code to the plugin code. In the file /membership/membershipincludes/addons/simple.invitecodes.php line 177, you will see a code block like this

    function M_RemoveSimpleInviteCode() {
        $Msi_options = M_get_option( 'membership_simpleinvite_options', array() );
    	if ( !isset( $Msi_options['inviteremove'] ) || !filter_var( $Msi_options['inviteremove'], FILTER_VALIDATE_BOOLEAN ) || !isset( $Msi_options['invitecodes'] ) ) {
    		return;
    	}
    
    	$thekey = filter_input( INPUT_POST, 'invitecode' );
    	$codes = array_map( 'trim', explode( PHP_EOL, $Msi_options['invitecodes'] ) );
    
       	$key = array_search( $thekey, $codes );
    	if ( $key !== false ) {
    
    		unset( $codes[$key] );
    		$Msi_options['invitecodes'] = implode( PHP_EOL, $codes );
    		M_update_option( 'membership_simpleinvite_options', $Msi_options );
    	}
    }

    Please update it like this

    function M_RemoveSimpleInviteCode() {
        $Msi_options = M_get_option( 'membership_simpleinvite_options', array() );
    	if ( !isset( $Msi_options['inviteremove'] ) || !filter_var( $Msi_options['inviteremove'], FILTER_VALIDATE_BOOLEAN ) || !isset( $Msi_options['invitecodes'] ) ) {
    		return;
    	}
    
    	$thekey = filter_input( INPUT_POST, 'invitecode' );
    	$codes = array_map( 'trim', explode( PHP_EOL, $Msi_options['invitecodes'] ) );
        //check does this key need to be removed or not
        $subscription_not_remove = 1;
        $subscription = isset( $_REQUEST['subscription'] ) ? $_REQUEST['subscription'] : 0;
        if($subscription==$subscription_not_remove){
            return;
        }
    
    	$key = array_search( $thekey, $codes );
    	if ( $key !== false ) {
    
    		unset( $codes[$key] );
    		$Msi_options['invitecodes'] = implode( PHP_EOL, $codes );
    		M_update_option( 'membership_simpleinvite_options', $Msi_options );
    	}
    }

    You will see the variable $subscription_not_remove = 1;, please update it value to the Subscription ID which you don't want to remove the Invite Code after user registered.

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.