UM_USERROLECHANGE::set_user_role( $user_id,  $role,  $old_roles )

Validation function when the trigger action is hit


Parameters Parameters

$user_id

(Required)

$role

(Required)

$old_roles

(Required)


Source Source

File: src/integrations/ultimate-member/triggers/um-userrolechange.php

	public function set_user_role( $user_id, $role, $old_roles ) {


		$matched_recipe_ids = $this->match_condition( $role );
		if ( ! empty( $matched_recipe_ids ) ) {
			foreach ( $matched_recipe_ids as $matched_recipe_id ) {
				$args = [
					'code'             => $this->trigger_code,
					'meta'             => $this->trigger_meta,
					'user_id'          => $user_id,
					'recipe_to_match'  => $matched_recipe_id['recipe_id'],
					'trigger_to_match' => $matched_recipe_id['trigger_id'],
					'ignore_post_id'   => true,
				];

				if ( isset( Automator()->process ) && isset( Automator()->process->user ) && Automator()->process->user instanceof Automator_Recipe_Process_User ) {
					Automator()->process->user->maybe_add_trigger_entry( $args );
				} else {
					Automator()->maybe_add_trigger_entry( $args );
				}
			}
		}

	}