UM_USERROLECHANGE::match_condition( $role )


Parameters Parameters

$role

(Required)


Top ↑

Return Return

(array)


Source Source

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

	public function match_condition( $role ) {

		$recipes            = Automator()->get->recipes_from_trigger_code( $this->trigger_code );
		$required_role      = Automator()->get->meta_from_recipes( $recipes, $this->trigger_meta );
		$matched_recipe_ids = array();

		//Add where option is set to Any product
		foreach ( $recipes as $recipe_id => $recipe ) {
			foreach ( $recipe['triggers'] as $trigger ) {
				$trigger_id = $trigger['ID'];//return early for all products
				if ( - 1 === intval( $required_role[ $recipe_id ][ $trigger_id ] ) ) {
					$matched_recipe_ids[] = [
						'recipe_id'  => $recipe_id,
						'trigger_id' => $trigger_id,
					];

					break;
				}
			}
		}

		//Add where Product ID is set for trigger
		foreach ( $recipes as $recipe_id => $recipe ) {
			foreach ( $recipe['triggers'] as $trigger ) {
				$trigger_id = $trigger['ID'];//return early for all products
				if ( $required_role[ $recipe_id ][ $trigger_id ] == $role ) {
					$matched_recipe_ids[] = [
						'recipe_id'  => $recipe_id,
						'trigger_id' => $trigger_id,
					];
				}
			}
		}

		return $matched_recipe_ids;
	}