Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter sameee49

    (@sameee49)

    By default the plugin do nothing… whenever a person is registered after referring from another already registered member by link. The plugin still shows zero invites. User b is not invented by any user…

    So for me. Plugin is showing me statis results of 0 invites and invited by none!
    How can i solve this issue?

    Thread Starter sameee49

    (@sameee49)

    function um_post_registration_approved_hook( $user_id, $args ) {
    	um_fetch_user( $user_id );
    	UM()->user()->approve();
    
    	//Referal System
    	$new_user_id = $user_id;
    	$ref_code = "";
    				
    	$new_user_ref_code = new WP_Refer_Code($new_user_id);
    	//Sprawdzamy czy textbox z jakiegos formularza zawiera kod referencyjny 
    	if($args["refferal"] != ""){
    		$ref_code = $args["refferal"];
    	}
    	else if($args["referal"] != ""){
    		$ref_code = $args["referal"];
    	}
    	else if($args["referall"] != ""){
    		$ref_code = $args["referall"];
    	}
    
    	if(!empty($ref_code) || $ref_code != ""){
    		$referrer_user_id = $new_user_ref_code->get_user_id_by_ref_code($ref_code);
    
    		do_action('wp_referral_code_before_refer_submitted', $new_user_id, $referrer_user_id, $ref_code, $new_user_ref_code);
    						
    		update_user_meta( $new_user_id, 'wrc_referrer_id', $referrer_user_id);
    						
    		$users_referred_by_referrer = get_user_meta( $referrer_user_id, 'wrc_invited_users', true );
    		if ( empty( $users_referred_by_referrer ) ) {
    			update_user_meta( $referrer_user_id, 'wrc_invited_users', [ $new_user_id ] );
    		} else {
    			$users_referred_by_referrer[] = $new_user_id;
    			update_user_meta( $referrer_user_id, 'wrc_invited_users', $users_referred_by_referrer );
    		}
    						
    		do_action( 'wp_referral_code_after_refer_submitted', $new_user_id, $referrer_user_id, $ref_code, $new_user_ref_code );
    	}
    }
    add_action( 'um_post_registration_approved_hook', 'um_post_registration_approved_hook', 10, 2 );

    This code??
    How can i put this? Should i simple post this at the end of the functions.php file???

    What changes do i have to make before pasting this code?

Viewing 2 replies - 1 through 2 (of 2 total)