### Start step JSON example
Source: https://docs.gravityflow.io/workflow-step-object/
Example of a workflow start step object in JSON format for the Gravity Flow REST API V2. Shows the structure with id, type, settings, and status fields.
```json
{
"id": 1179,
"type": "workflow_start",
"label": "Start",
"name": "Start",
"is_active": true,
"entry_count": 0,
"supports_expiration": false,
"assignees": [],
"settings": {
"step_name": "Start",
"description": "",
"step_type": "workflow_start",
"feed_condition_conditional_logic": "0",
"feed_condition_conditional_logic_object": [],
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_before_after": "after",
"schedule_date_field_offset": "0",
"schedule_date_field_offset_unit": "hours",
"instructionsEnable": "0",
"instructionsValue": "",
"display_fields_mode": "all_fields",
"destination_complete": "next",
"_entry_count": 0
},
"is_current_step": false,
"status": "complete",
"expiration_timestamp": false,
"is_expired": false,
"is_queued": false
}
```
--------------------------------
### start
Source: https://docs.gravityflow.io/step-class/
Attempts to start this step for the current entry. If the step is scheduled then the entry will be queued.
```APIDOC
## start
### Description
Attempts to start this step for the current entry. If the step is scheduled then the entry will be queued.
### Method
Function
### Parameters
None
### Returns
Boolean
```
--------------------------------
### Full example with enqueue and localize
Source: https://docs.gravityflow.io/gravityflow_enqueue_frontend_scripts/
Complete example that enqueues custom JavaScript and CSS, and localizes script data with AJAX URL and nonce.
```php
add_action( 'gravityflow_enqueue_frontend_scripts', 'gfw_custom_frontend_scripts' );
function gfw_custom_frontend_scripts() {
// Example: Enqueue custom JavaScript for Gravity Flow frontend
wp_enqueue_script(
'my-gravityflow-custom',
get_template_directory_uri() . '/js/gravityflow-custom.js',
array( 'jquery' ),
'1.0.0'
);
// Example: Enqueue custom CSS for Gravity Flow frontend styling
wp_enqueue_style(
'my-gravityflow-custom',
get_template_directory_uri() . '/css/gravityflow-custom.css',
array(),
'1.0.0'
);
// Example: Localize script with custom data
wp_localize_script( 'my-gravityflow-custom', 'myGravityFlowVars', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'my_custom_nonce' )
) );
}
```
--------------------------------
### entry_detail_status_box example (approval step)
Source: https://docs.gravityflow.io/step-class/
Example override of entry_detail_status_box that displays the step name, status, and assignee statuses. Uses evaluate_status(), get_name(), and get_assignees().
```php
public function entry_detail_status_box( $form ) {
$status = $this->evaluate_status();
?>
get_name() . ': ' . $status; ?>
get_assignees();
foreach ( $assignees as $assignee ) {
$assignee_status_label = $assignee->get_status_label();
$assignee_status_li = sprintf( '- %s
', $assignee_status_label );
echo $assignee_status_li;
}
?>
'complete',
'status_label' => __( 'Success', 'gravityflow' ),
'destination_setting_label' => esc_html__( 'Next Step if Success', 'gravityflow' ),
'default_destination' => 'next',
),
array(
'status' => 'error_client',
'status_label' => __( 'Error - Client', 'gravityflow' ),
'destination_setting_label' => esc_html__( 'Next Step if Client Error', 'gravityflow' ),
'default_destination' => 'complete',
),
array(
'status' => 'error_server',
'status_label' => __( 'Error - Server', 'gravityflow' ),
'destination_setting_label' => esc_html__( 'Next Step if Server Error', 'gravityflow' ),
'default_destination' => 'complete',
),
array(
'status' => 'error',
'status_label' => __( 'Error - Other', 'gravityflow' ),
'destination_setting_label' => esc_html__( 'Next step if Other Error', 'gravityflow' ),
'default_destination' => 'complete',
),
);
}
```
--------------------------------
### end method example (approval step)
Source: https://docs.gravityflow.io/step-class/
Example override of end that triggers status-based notifications and calls parent::end(). It sends approval/rejection notifications and performs post actions based on status.
```php
public function end() {
$status = $this->evaluate_status();
$entry = $this->get_entry();
if ( $status == 'approved' ) {
$this->send_approval_notification();
$this->maybe_perform_post_action( $entry, $this->publish_post_on_approval ? 'publish' : '' );
} elseif ( $status == 'rejected' ) {
$this->send_rejection_notification();
$this->maybe_perform_post_action( $entry, $this->post_action_on_rejection );
}
if ( $status == 'approved' || $status == 'rejected' ) {
GFAPI::send_notifications( $this->get_form(), $entry, 'workflow_approval' );
}
parent::end();
}
```
--------------------------------
### get_actions() override example for approval step
Source: https://docs.gravityflow.io/step-class/
Example override of get_actions that returns Approve and Reject actions with icons and note field visibility based on note mode.
```php
public function get_actions() {
return array(
array(
'key' => 'approve',
'label' => __( 'Approve', 'gravityflow' ),
'icon' => $this->get_approve_icon(),
'show_note_field' => in_array( $this->note_mode, array(
'required_if_approved',
'required_if_reverted_or_rejected',
'required',
)
),
),
array(
'key' => 'reject',
'label' => __( 'Reject', 'gravityflow' ),
'icon' => $this->get_reject_icon(),
'show_note_field' => in_array( $this->note_mode, array(
'required_if_rejected',
'required_if_reverted_or_rejected',
'required',
)
),
),
);
}
```
--------------------------------
### Combined example of gravityflow reports shortcode attributes
Source: https://docs.gravityflow.io/shortcodes/
Example combining form, category, range, and step_id attributes in a single shortcode.
```shortcode
[gravityflow page="reports" form="7" category="step" range="last-12-months" step_id="14"]
```
--------------------------------
### Example usage of process_assignee_status
Source: https://docs.gravityflow.io/step-class/
Example snippet showing how to call process_assignee_status when the assignee is the current user, used in the User Input step type.
```php
if ( $assignee->is_current_user() ) {
$feedback = $this->process_assignee_status( $assignee, $new_status, $form );
break;
}
```
--------------------------------
### get_settings() override example for feed add-on step
Source: https://docs.gravityflow.io/step-class/
Example override of get_settings that returns settings based on the feed type, including a title and fields from the feeds setting.
```php
public function get_settings() {
if ( ! $this->is_supported() ) {
return array();
}
return array(
'title' => $this->get_label(),
'fields' => array( $this->get_feeds_setting() ),
);
}
```
--------------------------------
### Hook registration example
Source: https://docs.gravityflow.io/gravityflow_enqueue_frontend_scripts/
Shows how to register a callback for the gravityflow_enqueue_frontend_scripts action using add_action.
```php
add_action( 'gravityflow_enqueue_frontend_scripts', 'my_custom_frontend_scripts', 10 );
```
--------------------------------
### status_evaluation override example from Gravity_Flow_Step_Feed_Add_On
Source: https://docs.gravityflow.io/step-class/
Example override that returns 'pending' until all feeds for the step have been added to the entry meta processed_feeds array.
```php
public function status_evaluation() {
$add_on_feeds = $this->get_processed_add_on_feeds();
$feeds = $this->get_feeds();
$form = $this->get_form();
$entry = $this->get_entry();
foreach ( $feeds as $feed ) {
$setting_key = 'feed_' . $feed['id'];
if ( $this->{$setting_key} && ! in_array( $feed['id'], $add_on_feeds ) && $this->is_feed_condition_met( $feed, $form, $entry ) ) {
return 'pending';
}
}
return 'complete';
}
```
--------------------------------
### GET /wp-json/gf/v2/entries/{entry_id}/workflows/steps
Source: https://docs.gravityflow.io/category/developers/
Retrieves all steps of the workflow for the specified entry. This endpoint is accessed via a GET request to the provided URL.
```APIDOC
## GET /wp-json/gf/v2/entries/{entry_id}/workflows/steps
### Description
Retrieves all steps of the workflow for the specified entry.
### Method
GET
### Endpoint
/wp-json/gf/v2/entries/{entry_id}/workflows/steps
### Parameters
#### Path Parameters
- **entry_id** (integer) - Required - The ID of the entry.
### Response
#### Success Response (200)
- **steps** (array) - List of workflow steps.
#### Response Example
{
"steps": []
}
```
--------------------------------
### Customize list field output in status table
Source: https://docs.gravityflow.io/gravityflow_field_value_status_table/
This example provides three starting points for customizing list field output in the status table. It shows how to display the HTML table version, a comma-separated list, or a custom unordered list built from the unserialized array.
```php
add_filter( 'gravityflow_field_value_status_table', 'sh_reformat_value_lists', 10, 4 );
function sh_reformat_value_lists( $value, $form_id, $column_name, $entry ) {
if ( $form_id == '76' && $column_name == '2' ) {
//This would give you the html table version
$value = html_entity_decode( $value );
$form = GFAPI::get_form( $form_id );
$field = GFFormsModel::get_field( $form, $column_name );
if ( $field ) {
//This will give you a , separated list of the values
$value = $field->get_value_entry_detail( $entry['2'], '', false, $format = 'text', 'screen' );
}
//Or you can use custom code with this starting point to build your own based on the array.
$list = maybe_unserialize( $entry['2'] );
if ( ! empty( $list ) ) {
$value = '';
foreach ( $list as $row ) {
$value .= '- ';
if ( is_array( $row ) ) {
foreach ( $row as $column ) {
$value .= '- ' . $column . '
';
}
} else {
$value .= $row;
}
$value .= ' ';
}
$value .= '
';
}
}
return $value;
}
```
--------------------------------
### GET /wp-json/gf/v2/forms/{form_id}/workflow/steps
Source: https://docs.gravityflow.io/gravity-flow-3-0-key-features/
Retrieves all steps for the specified form.
```APIDOC
## GET /wp-json/gf/v2/forms/{form_id}/workflow/steps
### Description
Retrieves all steps for the specified form.
### Method
GET
### Endpoint
/wp-json/gf/v2/forms/{form_id}/workflow/steps
### Parameters
#### Path Parameters
- **form_id** (integer) - Required - The ID of the form.
### Response
#### Success Response (200)
- **steps** (array) - List of workflow steps for the form.
#### Response Example
{
"steps": []
}
```
--------------------------------
### Get all the steps for a form
Source: https://docs.gravityflow.io/the-workflow-orchestration-api/
Instantiates the API and retrieves all steps for the form as an array of Gravity_Flow_Step objects.
```php
$api = new Gravity_Flow_API( $form_id );
/* @var Gravity_Flow_Step[] $steps */
$steps = $api->get_steps();
```
--------------------------------
### get_icon_url() override example for notification step
Source: https://docs.gravityflow.io/step-class/
Example override of get_icon_url that returns HTML markup for a font-awesome envelope icon.
```php
public function get_icon_url() {
return '';
}
```
--------------------------------
### GET /wp-json/gf/v2/entries/{entry_id}/workflow/steps
Source: https://docs.gravityflow.io/gravity-flow-3-0-key-features/
Retrieves all steps for the specified entry incl. current step status.
```APIDOC
## GET /wp-json/gf/v2/entries/{entry_id}/workflow/steps
### Description
Retrieves all steps for the specified entry incl. current step status.
### Method
GET
### Endpoint
/wp-json/gf/v2/entries/{entry_id}/workflow/steps
### Parameters
#### Path Parameters
- **entry_id** (integer) - Required - The ID of the entry.
### Response
#### Success Response (200)
- **steps** (array) - List of workflow steps for the entry.
#### Response Example
{
"steps": []
}
```
--------------------------------
### validate_status_update override example from User Input step type
Source: https://docs.gravityflow.io/step-class/
Example override that uses validate_note and get_validation_result to determine if the status update is valid.
```php
public function validate_status_update( $new_status, $form ) {
$valid = $this->validate_note( $new_status, $form );
return $this->get_validation_result( $valid, $form, $new_status );
}
```
--------------------------------
### is_complete() override example for outgoing webhook step
Source: https://docs.gravityflow.io/step-class/
Example override of is_complete that returns true when the status is not 'pending' or 'queued', using the evaluate_status function.
```php
public function is_complete() {
$status = $this->evaluate_status();
return ! in_array( $status, array( 'pending', 'queued' ) );
}
```
--------------------------------
### Example Response: {"result":"created"}
Source: https://docs.gravityflow.io/incoming-webhook-create-entry-rest-api-v2/
The expected response from the Incoming Webhook REST API v2 when the entry is successfully created.
```json
{"result":"created"}
```
--------------------------------
### get_required_capabilities
Source: https://docs.gravityflow.io/step-class/
Get required capabilities for the step.
```APIDOC
## get_required_capabilities
### Description
Get required capabilities for the step.
### Method
Function
### Signature
`get_required_capabilities()`
### Parameters
None
### Returns
- **Array** - The required capabilities.
```
--------------------------------
### GET /wp-json/gf/v2/forms/{form_id}/workflows/steps
Source: https://docs.gravityflow.io/category/developers/
Retrieves all steps of the workflow for the specified form. This endpoint is accessed via a GET request to the provided URL.
```APIDOC
## GET /wp-json/gf/v2/forms/{form_id}/workflows/steps
### Description
Retrieves all steps of the workflow for the specified form.
### Method
GET
### Endpoint
/wp-json/gf/v2/forms/{form_id}/workflows/steps
### Parameters
#### Path Parameters
- **form_id** (integer) - Required - The ID of the form.
### Response
#### Success Response (200)
- **steps** (array) - List of workflow steps.
#### Response Example
{
"steps": []
}
```
--------------------------------
### get_step_settings
Source: https://docs.gravityflow.io/step-class/
Get the settings for the current step. Defaults to empty get_settings() method.
```APIDOC
## get_step_settings
### Description
Get the settings for the current step. Defaults to empty get_settings() method.
### Method
Function
### Signature
`get_step_settings()`
### Parameters
None
### Returns
- **Array** - The step settings.
```
--------------------------------
### Get the current step
Source: https://docs.gravityflow.io/the-workflow-orchestration-api/
Retrieves the current step for a given entry. The entry is expected to be an array.
```php
$api = new Gravity_Flow_API( $form_id );
/*
@var Gravity_Flow_Step $step
@var array() $entry The Entry
*/
$step = $api->get_current_step( $entry );
```
--------------------------------
### is_queued
Source: https://docs.gravityflow.io/step-class/
Is the step currently in the queue waiting for the scheduled start time?
```APIDOC
## is_queued
### Description
Is the step currently in the queue waiting for the scheduled start time?
### Return Type
Boolean
### Parameters
None
```
--------------------------------
### process
Source: https://docs.gravityflow.io/step-class/
Process the step which is the core activity which the step is designed for. For example, assign to a user, send to a service, send a notification or trigger a feed for completion.
```APIDOC
## process
### Description
Process the step which is the core activity which the step is designed for. For example, assign to a user, send to a service, send a notification or trigger a feed for completion.
### Method
N/A (PHP method)
### Endpoint
N/A
### Parameters
None
### Returns
Boolean
### Source Code
```php
public function process() {
return true;
}
```
### Examples
The outgoing webhook step triggers its send_webhook function.
The approval and user input step types trigger their assign functions to determine assignees for their interactive steps.
```
--------------------------------
### validate_note_mode override example from User Input step type
Source: https://docs.gravityflow.io/step-class/
Example override that validates the note based on note mode settings (required, required if in progress, required if complete) and applies the 'gravityflow_note_valid' filter.
```php
public function validate_note_mode( $new_status, $note ) {
$note = trim( $note );
$valid = true;
switch ( $this->note_mode ) {
case 'required' :
if ( empty( $note ) ) {
$valid = false;
}
break;
case 'required_if_in_progress' :
if ( $new_status == 'in_progress' && empty( $note ) ) {
$valid = false;
};
break;
case 'required_if_complete' :
if ( $new_status == 'complete' && empty( $note ) ) {
$valid = false;
};
}
$valid = apply_filters( 'gravityflow_note_valid', $valid, $note, $new_status, $this );
return $valid;
}
```
--------------------------------
### Notification step JSON example
Source: https://docs.gravityflow.io/workflow-step-object/
Example of a notification workflow step object in JSON format for the Gravity Flow REST API V2. Shows the structure with id, type, settings, and routing configuration.
```json
{
"id": 77,
"type": "notification",
"label": "Notification",
"name": "Thank User",
"is_active": true,
"entry_count": 0,
"supports_expiration": false,
"assignees": [],
"settings": {
"step_name": "Thank User",
"description": "",
"step_type": "notification",
"step_highlight": "0",
"step_highlight_type": "color",
"step_highlight_color": "#dd3333",
"feed_condition_conditional_logic_object": [],
"feed_condition_conditional_logic": "0",
"scheduled": "0",
"schedule_type": "delay",
"schedule_date": "",
"schedule_delay_offset": "",
"schedule_delay_unit": "hours",
"schedule_date_field_offset": "",
"schedule_date_field_offset_unit": "hours",
"schedule_date_field_before_after": "after",
"notification_id_51794abf1f0d1": "1",
"workflow_notification_enabled": "0",
"workflow_notification_type": "select",
"workflow_notification_routing": [
{
"assignee": "user_id|1",
"fieldId": "0",
"operator": "is",
"value": "",
"type": ""
}
],
"workflow_notification_from_name": "",
"workflow_notification_from_email": "{admin_email}",
"workflow_notification_reply_to": "",
"workflow_notification_cc": "",
"workflow_notification_bcc": "",
"workflow_notification_subject": "",
"workflow_notification_message": "",
"workflow_notification_disable_autoformat": "0",
"destination_complete": "next",
"highlight": "",
"condition": "",
"notification": "",
"workflow_notification_users": "",
"workflow_notification_autoformat": "",
"_entry_count": 0
}
}
```
--------------------------------
### Add a custom toolbar menu item
Source: https://docs.gravityflow.io/gravityflow_toolbar_menu_items/
Example of adding a custom toolbar menu item that shows the Inbox page. The custom item is added to the $menu_items array and returned. The example includes a custom label, icon, tooltip, URL, CSS classes, capabilities, and priority.
```php
add_filter( 'gravityflow_toolbar_menu_items', 'gfw_custom_gravityflow_toolbar_item' );
function gfw_custom_gravityflow_toolbar_item( $menu_items ) {
$custom_item = array(
'label' => esc_html__( 'Custom Tab', 'text-domain' ),
'icon' => '',
'title' => __( 'Custom tab for workflow management', 'text-domain' ),
'url' => '?page=gravityflow-inbox',
'menu_class' => 'gf_form_toolbar_settings',
'link_class' => ( rgget( 'page' ) == 'gravityflow-inbox' ) ? 'gf_toolbar_active' : '',
'capabilities' => 'gravityflow_inbox',
'priority' => 500,
);
$menu_items['custom_tool'] = $custom_item;
return $menu_items;
}
```
--------------------------------
### PHP Request to Get Workflow Steps
Source: https://docs.gravityflow.io/get-steps-by-entry-with-rest-api-v2/
Uses wp_remote_post to call the GET endpoint /wp-json/gf/v2/entries/[entry_id]/workflow/steps with Basic authentication. Expects a 200 response code on success; otherwise retrieves the response message or WP_Error message.
```php
//Update these variables
$entry_id = '1273';
$domain = 'https://develop.local';
$auth_value = 'Basic replace-me-with-basic-auth-based-on-user-application-password';
// {@see https://codex.wordpress.org/HTTP_API}
$response = wp_remote_post( $domain . '/wp-json/gf/v2/entries/' . $entry_id . '/workflow/steps', array(
'headers' => array(
'Authorization' => $auth_value,
),
) );
if ( ! is_wp_error( $response ) ) {
// The request went through successfully, check the response code against
// what we're expecting
if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
// Do something with the response
// $body = wp_remote_retrieve_body( $response );
// $headers = wp_remote_retrieve_headers( $response );
} else {
// The response code was not what we were expecting, record the message
$error_message = wp_remote_retrieve_response_message( $response );
}
} else {
// There was an error making the request
$error_message = $response->get_error_message();
}
```
--------------------------------
### Example JSON for mapping array values with backslash notation
Source: https://docs.gravityflow.io/incoming-webhook-field-mapping/
Illustrates how to map values inside arrays or complex objects using backslash to drill down. For example, people\0\name maps 'Steve' to the field when the received JSON is {people: ["Steve", "Jamie"]}.
```json
{people: \[ "Steve", "Jamie" \]}
```
--------------------------------
### GET /wp-json/gf/v2/entries/{entry_id}/workflow/steps/{step_id}
Source: https://docs.gravityflow.io/gravity-flow-3-0-key-features/
Retrieves the specified step for the specified entry.
```APIDOC
## GET /wp-json/gf/v2/entries/{entry_id}/workflow/steps/{step_id}
### Description
Retrieves the specified step for the specified entry.
### Method
GET
### Endpoint
/wp-json/gf/v2/entries/{entry_id}/workflow/steps/{step_id}
### Parameters
#### Path Parameters
- **entry_id** (integer) - Required - The ID of the entry.
- **step_id** (integer) - Required - The ID of the step.
### Response
#### Success Response (200)
- **step** (object) - The requested workflow step.
#### Response Example
{
"step": {}
}
```
--------------------------------
### Get all the steps for a form
Source: https://docs.gravityflow.io/the-workflow-orchestration-api/
Retrieves all workflow steps associated with a form using the get_steps method.
```APIDOC
## get_steps()
### Description
Returns an array of Gravity_Flow_Step objects representing all steps for the form.
### Method
get_steps
### Parameters
None.
### Request Example
```php
$api = new Gravity_Flow_API( $form_id );
$steps = $api->get_steps();
```
### Response
- **$steps** (Gravity_Flow_Step[]) - Array of step objects.
```
--------------------------------
### GET /wp-json/gf/v2/entries/{entry_id}/workflow/steps/current
Source: https://docs.gravityflow.io/gravity-flow-3-0-key-features/
Retrieves the current step for the specified entry incl. current status.
```APIDOC
## GET /wp-json/gf/v2/entries/{entry_id}/workflow/steps/current
### Description
Retrieves the current step for the specified entry incl. current status.
### Method
GET
### Endpoint
/wp-json/gf/v2/entries/{entry_id}/workflow/steps/current
### Parameters
#### Path Parameters
- **entry_id** (integer) - Required - The ID of the entry.
### Response
#### Success Response (200)
- **step** (object) - The current workflow step.
#### Response Example
{
"step": {}
}
```
--------------------------------
### Filter to change capability for get forms steps
Source: https://docs.gravityflow.io/gravityflow_rest_api_capability_get_forms_steps/
This example changes the capability checked for the REST API endpoints that get workflow steps. It sets the capability to 'gravityflow_settings' instead of the default 'gravityflow_create_steps'. Place this code in functions.php, a custom functions plugin, a custom add-on, or a code snippets plugin.
```php
add_filter( 'gravityflow_rest_api_capability_get_forms_steps', 'flow_capability_form_steps_type', 10, 2 );
function flow_capability_form_steps_type( $capability, $request ) {
$capability = 'gravityflow_settings';
return $capability;
}
```
--------------------------------
### Replace entry ID with form field value using gravityflow_field_value_status_table
Source: https://docs.gravityflow.io/gravityflow_field_value_status_table/
Use this filter to replace the entry ID column value with a value from a form field. The example checks for form ID 2 and column 'id', then uses rgar() to get field 191 from the entry.
```php
add_filter( 'gravityflow_field_value_status_table', 'sh_gravityflow_field_value_status_table', 10, 4 );
function sh_gravityflow_field_value_status_table( $label, $form_id, $column_name, $entry ) {
if ( $form_id == 2 && $column_name == 'id' ) {
$label = rgar( $entry, '191' );
}
return $label;
}
```
--------------------------------
### PHP Request to Get Specific Step
Source: https://docs.gravityflow.io/get-specific-step-with-rest-api-v2/
Example PHP code using wp_remote_get to call the Gravity Flow REST API v2 endpoint. Requires updating the entry ID, step ID, domain, and authentication value. The response is checked for errors and the expected 200 status code.
```php
//Update these variables
$entry_id = '1273';
$step_id = '127';
$domain = 'https://develop.local';
$auth_value = 'Basic replace-me-with-basic-auth-based-on-user-application-password';
// {@see https://codex.wordpress.org/HTTP_API}
$response = wp_remote_get( $domain . '/wp-json/gravityflow/v2/entries/' . $entry_id . '/workflow/steps/' . $step_id, array(
'headers' => array(
'Authorization' => $auth_value,
),
) );
if ( ! is_wp_error( $response ) ) {
// The request went through successfully, check the response code against
// what we're expecting
if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
// Do something with the response
// $body = wp_remote_retrieve_body( $response );
// $headers = wp_remote_retrieve_headers( $response );
} else {
// The response code was not what we were expecting, record the message
$error_message = wp_remote_retrieve_response_message( $response );
}
} else {
// There was an error making the request
$error_message = $response->get_error_message();
}
```
--------------------------------
### Disable automatic major version updates with gravityflow_major_version_auto_updates_allowed
Source: https://docs.gravityflow.io/gravityflow_major_version_auto_updates_allowed/
Use this filter to prevent automatic installation of major Gravity Flow releases when automatic updates are enabled. The example returns false to disallow major version updates. Place this code in the active theme's functions.php, a custom functions plugin, a custom add-on, or a code snippets plugin.
```php
add_filter( 'gravityflow_major_version_auto_updates_allowed', '__return_false' );
```
--------------------------------
### PHP Request to Restart Step via REST API v2
Source: https://docs.gravityflow.io/restart-step-rest-api-v2/
Use this PHP snippet to restart a workflow step by sending a GET request to the Gravity Flow REST API v2 endpoint. It requires updating the $entry_id, $step_id, $domain, and $auth_value variables. The example checks for a 200 response code and handles errors using is_wp_error and wp_remote_retrieve_response_message.
```php
//Update these variables
$entry_id = '1273';
$step_id = '127';
$domain = 'https://develop.local';
$auth_value = 'Basic replace-me-with-basic-auth-based-on-user-application-password';
// {@see https://codex.wordpress.org/HTTP_API}
$response = wp_remote_get( $domain . '/wp-json/gravityflow/v2/entries/' . $entry_id . '/workflow/steps/' . $step_id . '/restart', array(
'headers' => array(
'Authorization' => $auth_value,
),
) );
if ( ! is_wp_error( $response ) ) {
// The request went through successfully, check the response code against
// what we're expecting
if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
// Do something with the response
// $body = wp_remote_retrieve_body( $response );
// $headers = wp_remote_retrieve_headers( $response );
} else {
// The response code was not what we were expecting, record the message
$error_message = wp_remote_retrieve_response_message( $response );
}
} else {
// There was an error making the request
$error_message = $response->get_error_message();
}
```
--------------------------------
### Access step setting value in process()
Source: https://docs.gravityflow.io/the-workflow-step-framework/
Shows how to read a setting value using $this->setting_name. The example dumps the value of 'custom_setting' to the output. The process() method must return a boolean indicating step completion.
```php
/**
* Process the step.
*
* @return bool Is the step complete?
*/
public function process(){
// Do something here.
var_dump( 'Setting: ' . $this->custom_setting );
}
```
--------------------------------
### GET /wp-json/gf/v2/entries/{entry_id}/workflows/status
Source: https://docs.gravityflow.io/category/developers/
Gets the workflow status, and current step details if available, for an existing entry. This endpoint is accessed via a GET request to the provided URL.
```APIDOC
## GET /wp-json/gf/v2/entries/{entry_id}/workflows/status
### Description
Gets the workflow status, and current step details if available, for an existing entry.
### Method
GET
### Endpoint
/wp-json/gf/v2/entries/{entry_id}/workflows/status
### Parameters
#### Path Parameters
- **entry_id** (integer) - Required - The ID of the entry.
### Response
#### Success Response (200)
- **status** (string) - The workflow status.
- **current_step** (object) - The current step details, if available.
#### Response Example
{
"status": "pending",
"current_step": {}
}
```
--------------------------------
### is_supported
Source: https://docs.gravityflow.io/step-class/
Is this step supported on this server? Override to hide this step in the list of step types if the requirements are not met.
```APIDOC
## is_supported
### Description
Is this step supported on this server? Override to hide this step in the list of step types if the requirements are not met.
### Return Type
Boolean
### Parameters
None
```
--------------------------------
### maybe_filter_validation_result() override example for approval step
Source: https://docs.gravityflow.io/step-class/
Example override of maybe_filter_validation_result that applies the 'gravityflow_validation_approval' filter to the validation result.
```php
public function maybe_filter_validation_result( $validation_result, $new_status ) {
return apply_filters( 'gravityflow_validation_approval', $validation_result, $this );
}
```
--------------------------------
### get_settings
Source: https://docs.gravityflow.io/step-class/
Override this method to add settings to the step. Use the Gravity Forms Add-On Framework Settings API.
```APIDOC
## get_settings
### Description
Override this method to add settings to the step. Use the [Gravity Forms Add-On Framework Settings API](https://docs.gravityforms.com/category/developers/php-api/add-on-framework/settings-api/).
### Method
PHP Method
### Endpoint
`public function get_settings()`
### Parameters
None
### Returns
[Array](https://docs.gravityforms.com/array)
### Example
This example shows how the [Gravity_Flow_Step_Feed_Add_On step type](https://docs.gravityflow.io/step_feed_class/) provides settings based on the feed type it is associated with.
```php
public function get_settings() {
if ( ! $this->is_supported() ) {
return array();
}
return array(
'title' => $this->get_label(),
'fields' => array( $this->get_feeds_setting() ),
);
}
```
```
--------------------------------
### get_label() override example for outgoing webhook step
Source: https://docs.gravityflow.io/step-class/
Example override of get_label that returns an escaped, translatable label 'Outgoing Webhook'.
```php
public function get_label() {
return esc_html__( 'Outgoing Webhook', 'gravityflow' );
}
```
--------------------------------
### get_settings() default source code
Source: https://docs.gravityflow.io/step-class/
Default implementation of the get_settings method, which returns nothing. Override this method to add settings to the step using the Gravity Forms Add-On Framework Settings API.
```php
public function get_settings( ) { }
```
--------------------------------
### process method
Source: https://docs.gravityflow.io/step-class/
Processes the step's core activity. Returns true by default. Overridden by outgoing webhook, approval, and user input step types.
```php
public function process() {
return true;
}
```
--------------------------------
### get_setting
Source: https://docs.gravityflow.io/step-class/
Returns the correct value for the step setting for the current context – either step settings or step processing.
```APIDOC
## get_setting
### Description
Returns the correct value for the step setting for the current context – either step settings or step processing.
### Method
Function
### Signature
`get_setting( $setting )`
### Parameters
- **$setting** (String) - Required - The setting name.
### Returns
- **Mixed** - The setting value.
```
--------------------------------
### GET /gf/v2/entries/{entry_id}/workflow/steps/current
Source: https://docs.gravityflow.io/category/developers/
Retrieves the current step of the workflow for the specified entry. This endpoint is accessed via a GET request to the provided URL.
```APIDOC
## GET /gf/v2/entries/{entry_id}/workflow/steps/current
### Description
Retrieves the current step of the workflow for the specified entry.
### Method
GET
### Endpoint
/gf/v2/entries/{entry_id}/workflow/steps/current
### Parameters
#### Path Parameters
- **entry_id** (integer) - Required - The ID of the entry.
### Response
#### Success Response (200)
- **step** (object) - The current step details.
#### Response Example
{
"step": {}
}
```
--------------------------------
### GET /gf/v2/entries/{entry_id}/workflow/steps/{step_id}
Source: https://docs.gravityflow.io/category/developers/
Retrieves a specific step of the workflow for the specified entry. This endpoint is accessed via a GET request to the provided URL.
```APIDOC
## GET /gf/v2/entries/{entry_id}/workflow/steps/{step_id}
### Description
Retrieves a specific step of the workflow for the specified entry.
### Method
GET
### Endpoint
/gf/v2/entries/{entry_id}/workflow/steps/{step_id}
### Parameters
#### Path Parameters
- **entry_id** (integer) - Required - The ID of the entry.
- **step_id** (integer) - Required - The ID of the step.
### Response
#### Success Response (200)
- **step** (object) - The step details.
#### Response Example
{
"step": {}
}
```
--------------------------------
### Simple custom step class extending Gravity_Flow_Step
Source: https://docs.gravityflow.io/the-workflow-step-framework/
Defines a minimal custom step type by extending Gravity_Flow_Step, registering it with Gravity_Flow_Steps::register(). The process() method is where custom logic goes; it is called automatically when the step is reached. No custom settings are added, but default settings (scheduling, conditional logic, Next Step) appear automatically.
```PHP
/**
* Wait until Gravity Flow is ready before declaring the step class.
*/
add_action( 'gravityflow_loaded', function(){
class Gravity_Flow_Step_Simple_Process extends Gravity_Flow_Step {
// Make this unique
public $_step_type = 'simple_process';
/**
* Returns the label for the step type.
*
* @return string
*/
public function get_label() {
return 'My Custom Step';
}
/**
* Process the step.
*
* @return bool Is the step complete?
*/
public function process(){
// Do something here.
}
}
// Register the step
Gravity_Flow_Steps::register( new Gravity_Flow_Step_Simple_Process() );
});
```
--------------------------------
### Basic cURL POST to Create Entry
Source: https://docs.gravityflow.io/incoming-webhook-create-an-entry/
Sends a JSON POST request to the Incoming Webhook URL. Replace [Your Webhook URL] and field keys to match your Field Values mapping. A successful request returns a 200 response and the new entry ID; 400/500 responses indicate mismatched Content-Type or field keys.
```bash
curl -X "POST" "[Your Webhook URL]" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"input_1": "Jane Doe",
"input_2": "jane@example.com",
"input_3": "This is a value from the API request."
}'
```
--------------------------------
### Disable automatic formatting on all instructions
Source: https://docs.gravityflow.io/gravityflow_auto_format_instructions/
Complete example that registers the filter and returns false to disable automatic formatting on all workflow step instructions. Place in functions.php or a custom plugin.
```php
add_filter( 'gravityflow_auto_format_instructions', 'sh_gravityflow_auto_format_instructions', 10, 1);
function sh_gravityflow_auto_format_instructions( $enable_formatting ) {
return false;
}
```
--------------------------------
### Register gravityflow_auto_format_instructions filter (generic and form-specific)
Source: https://docs.gravityflow.io/gravityflow_auto_format_instructions/
Shows the filter registration lines for both the generic filter and the form-specific variant (gravityflow_auto_format_instructions_12). Place these in functions.php or a custom plugin.
```php
add_filter( 'gravityflow_auto_format_instructions', 'sh_gravityflow_auto_format_instructions', 10, 1 );
add_filter( 'gravityflow_auto_format_instructions_12', 'sh_gravityflow_auto_format_instructions_form_12', 10, 1 );
```
--------------------------------
### maybe_adjust_assignment
Source: https://docs.gravityflow.io/step-class/
Removes assignees from and/or adds assignees to a step. Call after updating entry values. Make sure you call get_assignees() to get the assignees before you update the entry or the previous assignees may not get removed.
```APIDOC
## maybe_adjust_assignment
### Description
Removes assignees from and/or adds assignees to a step. Call after updating entry values. Make sure you call get_assignees() to get the assignees before you update the entry or the previous assignees may not get removed.
### Method
Function
### Parameters
- **$previous_assignee** (Assignee) - Required - The previous assignee.
### Returns
None
```
--------------------------------
### get_actions
Source: https://docs.gravityflow.io/step-class/
Returns an array of quick actions to be displayed on the inbox. The default return is an empty array.
```APIDOC
## get_actions
### Description
Returns an array of quick actions to be displayed on the inbox. The default return is an empty array.
### Method
PHP Method
### Endpoint
`public function get_actions()`
### Parameters
None
### Returns
[Array](https://docs.gravityforms.com/array)
### Example
The approval step overrides the get_actions method to provide Approve and Reject actions.
```php
public function get_actions() {
return array(
array(
'key' => 'approve',
'label' => __( 'Approve', 'gravityflow' ),
'icon' => $this->get_approve_icon(),
'show_note_field' => in_array( $this->note_mode, array(
'required_if_approved',
'required_if_reverted_or_rejected',
'required',
)
),
),
array(
'key' => 'reject',
'label' => __( 'Reject', 'gravityflow' ),
'icon' => $this->get_reject_icon(),
'show_note_field' => in_array( $this->note_mode, array(
'required_if_rejected',
'required_if_reverted_or_rejected',
'required',
)
),
),
);
}
```
```
--------------------------------
### get_validation_result
Source: https://docs.gravityflow.io/step-class/
Get the validation result for this step.
```APIDOC
## get_validation_result
### Description
Get the validation result for this step.
### Return Type
Array or Boolean or WP_Error
### Parameters
- **$valid** (Boolean) - Required - The validity flag.
- **$form** (Form) - Required - The form object.
- **$new_status** (String) - Required - The new status.
```
--------------------------------
### get_form
Source: https://docs.gravityflow.io/step-class/
Returns the Form object for this step.
```APIDOC
## get_form
### Description
Returns the Form object for this step.
### Method
Function
### Signature
`get_form()`
### Parameters
None
### Returns
- **Form** - The Form object.
```
--------------------------------
### GET Forms Steps REST API v1
Source: https://docs.gravityflow.io/the-workflow-web-rest-api/
Retrieves all steps defined on a form, while the Get Entry Steps endpoint retrieves the steps for a specific entry, including which step is active and its assignee status. This endpoint is part of the REST API v1.
```APIDOC
## GET Forms Steps REST API v1
### Description
Retrieves all steps defined on a form, while the Get Entry Steps endpoint retrieves the steps for a specific entry, including which step is active and its assignee status.
### Method
GET
### Endpoint
Not specified in source.
```