Warning: This method has been deprecated.

Automator_Recipe_Process_User::update_trigger_meta( $user_id = null,  $trigger_id = null,  $meta_key = null,  $meta_value = '',  $trigger_log_id = null )

Update the trigger for the user


Parameters Parameters

$user_id

(Optional) null

Default value: null

$trigger_id

(Optional) null

Default value: null

$meta_key

(Optional) null

Default value: null

$meta_value

(Optional) string

Default value: ''

$trigger_log_id

(Optional)

Default value: null


Top ↑

Return Return

(null)


Source Source

File: src/core/lib/process/class-automator-recipe-process-user.php

	public function update_trigger_meta( $user_id = null, $trigger_id = null, $meta_key = null, $meta_value = '', $trigger_log_id = null ) {

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

		// No user id is aviable.
		if ( 0 === $user_id ) {
			Automator()->error->add_error( 'update_trigger_meta', 'ERROR: You are trying to update trigger meta when a there is no logged in user.', $this );

			return null;
		}

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

			return null;
		}

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

			return null;
		}

		$update = array(
			'meta_value' => $meta_value,
			'run_time'   => current_time( 'mysql' ),
		);

		$where = array(
			'user_id'              => $user_id,
			'automator_trigger_id' => $trigger_id,
			'meta_key'             => $meta_key,
		);

		if ( ! empty( $trigger_log_id ) && is_numeric( $trigger_log_id ) ) {
			$where['automator_trigger_log_id'] = (int) $trigger_log_id;
		}

		$update_format = array(
			'%d',
			'%s',
		);

		$where_format = array(
			'%d',
			'%d',
			'%s',
		);

		if ( ! empty( $trigger_log_id ) && is_numeric( $trigger_log_id ) ) {
			$where_format[] = '%d';
		}

		return Automator()->db->trigger->update(
			$update,
			$where,
			$update_format,
			$where_format
		);
	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0 Introduced.