Automator_Recipe_Process_Complete::create_action( null $user_id = null, null $action_data = null, null $recipe_id = null, string $error_message = '', null $recipe_log_id = null, array $args = array() )


Parameters Parameters

$user_id

(null) (Optional)

Default value: null

$action_data

(null) (Optional)

Default value: null

$recipe_id

(null) (Optional)

Default value: null

$error_message

(string) (Optional)

Default value: ''

$recipe_log_id

(null) (Optional)

Default value: null

$args

(array) (Optional)

Default value: array()


Top ↑

Return Return

(bool)


Source Source

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

	public function create_action( $user_id = null, $action_data = null, $recipe_id = null, $error_message = '', $recipe_log_id = null, $args = array() ) {

		$action_id     = (int) $action_data['ID'];
		$completed     = (int) $action_data['completed'];
		$date_time     = apply_filters( 'automator_action_log_date_time', null, $action_data );
		$values        = array(
			'user_id'       => $user_id,
			'action_id'     => $action_id,
			'recipe_id'     => $recipe_id,
			'recipe_log_id' => $recipe_log_id,
			'completed'     => $completed,
			'error_message' => $error_message,
			'date_time'     => $date_time,
		);
		$action_log_id = Automator()->db->action->add( $values );
		$sentences     = Automator()->get->action_sentence( $action_id );
		if ( ! empty( $sentences ) ) {
			foreach ( $sentences as $meta_key => $meta_value ) {
				if ( ! empty( $meta_value ) ) {
					Automator()->db->action->add_meta( $user_id, $action_log_id, $action_id, $meta_key, maybe_serialize( $meta_value ) );
				}
			}
		}

		return $action_log_id;
	}