Workflow Variables
When you create a workflow and configure actions and triggers, you can specify variables in the trigger and action setting fields. These variables enable you to get and process actual values during the execution of the workflow.
All workflows have access to global variables, special built-in WordPress variables, variables generated by the workflow, custom-defined lists, and PHP constants. All variables are populated with real values during the execution of a workflow. Using variables in actions and triggers enables a workflow to process actual, live values.
To specify a variable, you need to use a special syntax. A variable starts and ends with two curly brackets {}
. The name of a variable is enclosed inside of them. All variable names are case-sensitive.
Any variable can either contain a single value like a string (number) or can contain a list with a set of values.
Example 1: {HOME}
The home URL of the website.
Example 2: {USER.user_email}
The email address of the currently logged-in WordPress user.
If a particular variable is a list, and you need to get the value of an element, you need to specify the variable name with a key (index). The terms key and index are used interchangeably and mean the same thing – a reference to a single element in an array. Typically we use index when we refer to a numeric key. To specify a list key, you need to use dot notation. Every key is separated from the variable name with a dot.
Example 3: {USER.roles}
This is a list of roles currently logged-in WordPress user has. We use dot because the variable USER contains multiple values; thus, it’s a list.
Example 4: {$post.post_title}
This global WordPress variable contains the title of the currently displayed post. It also contains various details about the currently displayed post. For instance, to get the content of the post, use this variable {$post.post_content}
.
Note: all variable names and list keys are case-sensitive.
Variables available in a workflow
Note: a variable can contain a string, number, list, or a Boolean logical value that has two values: false and true.
|
Data generated by a workflow trigger. |
|
Arguments passed to the workflow by WordPress, a parent workflow, or any other calling party.
If you want to create a workflow that filters out a value passed by WordPress, you can get that value by using the variable |
|
Data generated by the first action in the workflow. This data is a result of the execution of the first action. |
|
Data generated by the previous action in the workflow. This data is a result of the execution of the previous action. |
|
The list containing information pertaining to the currently logged-in WordPress user. For instance, to get the email address of the current user, you need to use the variable {USER.user_email} . You can use it, for instance, to send a notification to the user by using actions like Send email.
|
|
Current date and/or time formatted according to the given format string. Example: the variable {DATE[F j, Y, g:i a]} returns string March 10, 2020, 5:16 pm. Read more about formatting dates and time: http://php.net/manual/en/function.date.php |
|
Technical details about client’s computer such as IP address {CLIENT.ip} and hostname {CLIENT.hostname} . If WP Cerber Professional is installed, it also contains the country name {CLIENT.country} and the country ISO code {CLIENT.country.code} . |
|
The home URL of the website without trailing slash. For instance, for our jetFlow.io website, it returns the string: https://jetflow.io |
Global PHP variables
To get the value of a globally accessible PHP variable, prepend its name with the $ symbol like this:{$post}
. If a particular variable contains a list, you can specify the key of an element by using the dot, e.g. {$post.post_title}
to get the value of the element. For multilevel lists, use several keys separated with several dots. Some useful WordPress variables are described here: https://codex.wordpress.org/Global_Variables
PHP Constants
To get the value of any PHP constant, prepend its name with the percentage symbol % inside the curly brackets. For instance: {%WP_CONTENT_DIR}
and {%WP_DEBUG}
return values of WP_CONTENT_DIR and WP_DEBUG constants, respectively.
Nested lists
A list can be multi-dimensional or having a nested list, meaning each element of the list contains another list. For instance, this type of list is generated by the Get list of post and Get list of files actions. In such cases, to get the value of an element in the list, you have to specify a variable with two or more keys. For instance, {PREVIOUS.0.post_title}
gives you the post title of the first post in the list generated in the previous action. The first element in a list always has a zero key (index). To iterate over a list you can use Iterate next action.
Typecasting
If you need to get the value of a variable without type conversion (typecasting), you have to specify only one variable of any kind. If you specify more than one variable or enter some text along with some variable, all variables will be converted to a string containing respective values.
Read more
The {USER} variable contains information pertaining to the currently logged-in WordPress user