Automator_DB_Handler_Triggers::add_token_meta( $meta_key,  $meta_value,  $args )


Parameters Parameters

$args

(Required)

$meta_key

(Required)

$meta_value

(Required)


Top ↑

Return Return

(bool|int|null)


Source Source

File: src/core/lib/utilities/db/class-automator-db-handler-triggers.php

	public function add_token_meta( string $meta_key, string $meta_value, array $args ) {
		$trigger_id     = isset( $args['trigger_id'] ) ? absint( $args['trigger_id'] ) : null;
		$trigger_log_id = isset( $args['trigger_log_id'] ) ? absint( $args['trigger_log_id'] ) : null;
		$run_number     = isset( $args['run_number'] ) ? absint( $args['run_number'] ) : null;
		$user_id        = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : null;
		// Set user ID
		if ( is_null( $user_id ) ) {
			$user_id = get_current_user_id();
		}

		if ( null === $trigger_log_id || ! is_numeric( $trigger_log_id ) ) {
			Automator()->error->add_error( 'insert_trigger_token_meta', 'ERROR: You are trying to insert trigger meta without providing valid trigger_log_id', $this );

			return null;
		}

		if ( empty( $meta_key ) ) {
			Automator()->error->add_error( 'insert_trigger_token_meta', 'ERROR: You are trying to insert trigger meta without providing a meta_key', $this );

			return null;
		}

		if ( empty( $meta_value ) ) {
			Automator()->error->add_error( 'insert_trigger_token_meta', 'ERROR: You are trying to insert trigger meta without providing a meta_value', $this );

			return null;
		}
		$token_args = array(
			'user_id'    => $user_id,
			'meta_key'   => $meta_key,
			'meta_value' => $meta_value,
		);

		return $this->add_meta( $trigger_id, $trigger_log_id, $run_number, $token_args );
	}