Automator_Get_Data::trigger_run_number( $trigger_id,  $trigger_log_id,  $user_id )


Parameters Parameters

$trigger_id

(Required)

$trigger_log_id

(Required)

$user_id

(Required)


Top ↑

Return Return

(int|null|string)


Source Source

File: src/core/lib/utilities/class-automator-get-data.php

	public function trigger_run_number( $trigger_id, $trigger_log_id, $user_id ) {
		// Seems like Anonymous trigger. Return 1.
		if ( 0 === absint( $user_id ) ) {
			return 1;
		}

		global $wpdb;

		$run_number = $wpdb->get_var(
			$wpdb->prepare(
				"SELECT MAX(run_number)
					FROM {$wpdb->prefix}uap_trigger_log_meta
					WHERE 1=1
					AND user_id = %d
					AND automator_trigger_id = %d
					AND automator_trigger_log_id = %d",
				$user_id,
				$trigger_id,
				$trigger_log_id
			)
		);

		if ( empty( $run_number ) ) {
			return 1;
		}

		return $run_number;
	}