Automator_Get_Data::trigger_meta( null $user_id = null, null $trigger_id = null, null $meta_key = null,  $trigger_log_id = null )

Get the trigger for the user


Parameters Parameters

$user_id

(null) (Optional)

Default value: null

$trigger_id

(null) (Optional)

Default value: null

$meta_key

(null) (Optional)

Default value: null

$trigger_log_id

(Optional)

Default value: null


Top ↑

Return Return

(null|string)


Source Source

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

	public function trigger_meta( $user_id = null, $trigger_id = null, $meta_key = null, $trigger_log_id = null ) {

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

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

			return null;
		}

		if ( null === $meta_key || ! is_string( $meta_key ) ) {
			Automator()->error->add_error( 'trigger_meta', 'ERROR: You are trying to get trigger meta without providing a meta_key', $this );

			return null;
		}

		global $wpdb;

		return $wpdb->get_var(
			$wpdb->prepare(
				"SELECT COUNT(meta_value) FROM {$wpdb->prefix}uap_trigger_log_meta WHERE user_id = %d AND meta_key LIKE %s AND automator_trigger_id = %d AND automator_trigger_log_id = %d",
				$user_id,
				$meta_key,
				$trigger_id,
				$trigger_log_id
			)
		);
	}