WM_ADDUSER_A::add_user_to_membership_levels( $user_id,  $action_data,  $recipe_id,  $args )

Validation function when the trigger action is hit


Parameters Parameters

$user_id

(Required)

$action_data

(Required)

$recipe_id

(Required)


Source Source

File: src/integrations/wishlist-member/actions/wm-adduser-a.php

	public function add_user_to_membership_levels( $user_id, $action_data, $recipe_id, $args ) {
		global $WishListMemberInstance;


		$level_ids = array();
		$wm_level  = $action_data['meta'][ $this->action_meta ];

		if ( $wm_level == '-1' ) {
			$all_levels = $WishListMemberInstance->GetOption( 'wpm_levels' );
			if ( is_array( $all_levels ) ) {
				foreach ( $all_levels as $Id => $levels ) {
					$level_ids = $Id;
				}
			}
		} else {
			$level_ids = $WishListMemberInstance->GetMembershipLevels( $user_id );
			if ( ! in_array( $wm_level, $level_ids ) ) {
				$level_ids[] = $wm_level;
			}
		}

		$WishListMemberInstance->SetMembershipLevels( $user_id, $level_ids );
		Automator()->complete_action( $user_id, $action_data, $recipe_id );
	}