Automator_Get_Data::trigger_log_id( $user_id = null,  $trigger_id = null, null $recipe_id = null, null $recipe_log_id = null )

Get the trigger log ID for the user


Parameters Parameters

$user_id

(Optional) null

Default value: null

$trigger_id

(Optional) null

Default value: null

$recipe_id

(null) (Optional) null

Default value: null

$recipe_log_id

(null) (Optional) null

Default value: null


Top ↑

Return Return

(null|int)


Source Source

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

	public function trigger_log_id( $user_id = null, $trigger_id = null, $recipe_id = null, $recipe_log_id = null ) {

		// Set user ID
		if ( is_null( $user_id ) ) {
			$user_id = get_current_user_id();
		}

		if ( null === $trigger_id || ! is_numeric( $trigger_id ) ) {
			Automator()->error->add_error( 'trigger_log_id', 'ERROR: You are trying to get a trigger log ID without providing a trigger_id', $this );

			return null;
		}

		if ( null === $recipe_id || ! is_numeric( $recipe_id ) ) {
			Automator()->error->add_error( 'trigger_log_id', 'ERROR: You are trying to get a trigger lod ID without providing a recipe_id', $this );

			return null;
		}

		global $wpdb;
		$results = $wpdb->get_var(
			$wpdb->prepare(
				"SELECT ID FROM {$wpdb->prefix}uap_trigger_log WHERE user_id = %d AND automator_trigger_id = %d AND automator_recipe_id = %d AND automator_recipe_log_id = %d",
				$user_id,
				$trigger_id,
				$recipe_id,
				$recipe_log_id
			)
		);

		if ( empty( $results ) ) {
			return null;
		}

		return (int) $results;
	}