This site is automated with JetFlow.io plugin and protected with WP Cerber security plugin

Newsletter Subscription

If you want to subscribe to our monthly newsletter, please submit the form below.

 

Variables and constants patterns

jetFlow.io > Documentation  > Variables and patterns  > Variables and constants patterns

Variables and constants patterns

When you will create a workflow you will use special patterns in setting fields of actions and triggers to get values of variables that belong to currently executing workflow, system variables, WordPress global variable and constants. During the execution of the workflow all of the patterns will be replaced with actual values.

Every workflow has access to global variables, special built-in variables created by WordPress, variables created by workflow triggers and actions, PHP constants. Below you can get the explanation about patterns that you can use in any settings fields of the actions and triggers.

Any variable pattern starts and ends with curly braces {} and variable names are written inside of curly braces.

Any variable can have a single value like a string or can have a complex value like list with a set of values. If the particular variable is a list, you have to use pattern with a key (index) to get single value from the list. We will use the term key or index to mean the same thing. The key must be written inside of square brackets []. Sometimes, depends on context, you may use a list without index. Sometimes, list can be a multilevel list.

Example: {$post[post_title]}. This pattern returns a title of currently displayed post. In this pattern we use a global WordPress variable $post, that actually is a list and contains various details about currently displayed post, and a key post_title. To get a content of the post we need to use pattern {$post[post_content]} respectively.

Example: {USER[roles]}. This pattern is not a single value, but represents a list of roles currently logged in WordPress user has.

Built-in variables

Note: any variable can be a string, number, list or a Boolean logical value that has two values: false and true.

{TRIGGER}
Data generated by a trigger that has started currently executing workflow.
{ARG}
List of arguments passed to the workflow by WordPress, parent workflow or any other calling party.

If you want to create a workflow which have to filter out value passed by WordPress, you can get value passed by WordPress by using pattern {ARG[0]}. Read more: Using workflow as WordPress filter.

{FIRST}
Data generated by a first action in the workflow. This data is a result of the execution of the first action.
{PREVIOUS}
Data generated by a previous action in the workflow. This data is a result of the execution of the previous action.
{USER}
List with information pertaining to the currently logged in WordPress user. For instance, to get email address of the current user, you need to use pattern {USER[user_email]}. You may use it, for instance, to send some email notification to the user with action like Send email.

Read more here: http://jetflow.io/docs/creating-workflow/variable-user/

{DATE[format]}
Return date and time string formatted according to the given format string. Example: pattern {DATE[F j, Y, g:i a]} will return string March 10, 2016, 5:16 pm. Read more about formatting dates and time: http://php.net/manual/en/function.date.php

 

Global PHP variables

Pattern to get the value of any globally accessible PHP variable starts with symbol $ inside curly braces like {$post}. If particular variable is an array (list) you may specify index within square brackets like this {$post[post_title]}. Some useful WordPress variables are described here: https://codex.wordpress.org/Global_Variables

PHP Constants

Pattern to get the value of any PHP constant starts with % inside curly braces. For instance: {%WP_CONTENT_DIR} or {%WP_DEBUG} will return values of WP_CONTENT_DIR and WP_DEBUG constant repsectively.

Nested lists

Some values can be a two-level or nested list. This means that every element of a particular list contains another list (second level). For instance, such kind of list will be produced by  Get list of post and Get list of files actions. In that case to get access to some element of list you have to use pattern with two keys like {PREVIOUS[0][post_title]} to get the post title of the first post in a list. Yes, first element in a list will have 0 key. To iterate over such kind of list you can use Iterate next action.

Typecasting

If you want to get and use value of a certain variable without type conversion (typecasting), you have to specify only one pattern any kind in the configuration field of an action or a trigger. If you specify more than one pattern or enter some text along with some pattern, all variables will be converted to a string containing respective values.

No Comments

Sorry, the comment form is closed at this time.