The gform_update_status action hook in Gravity Forms is a dynamically generated filter name. It is used to modify the behavior of the form based on the entry’s status.
Usage
add_action('gform_update_status', 'your_custom_function', 10, 3); function your_custom_function($form_id, $entry_id, $status) { // Your custom code here return $status; }
Parameters
- $form_id (int): The ID of the form being processed.
- $entry_id (int): The ID of the entry being updated.
- $status (string): The entry’s status being updated.
More information
See Gravity Forms Docs: gform_update_status
Examples
Change status to “Completed” after payment
Automatically change the entry status to “Completed” after a successful payment.
add_action('gform_update_status', 'update_status_after_payment', 10, 3); function update_status_after_payment($form_id, $entry_id, $status) { if ($status == 'Paid') { return 'Completed'; } return $status; }
Add a custom status for entries
Create a custom status for entries that meet specific criteria.
add_action('gform_update_status', 'add_custom_status', 10, 3); function add_custom_status($form_id, $entry_id, $status) { // Check if the form ID matches your target form if ($form_id == 3) { // Check if the entry status is "Approved" if ($status == 'Approved') { return 'CustomStatus'; } } return $status; }
Log status changes
Log every time an entry’s status is changed.
add_action('gform_update_status', 'log_status_changes', 10, 3); function log_status_changes($form_id, $entry_id, $status) { error_log("Form ID: {$form_id} - Entry ID: {$entry_id} - Status: {$status}"); return $status; }
Send email notification when status changes to “Completed”
Send an email to the admin when the entry status is updated to “Completed”.
add_action('gform_update_status', 'send_email_on_completed', 10, 3); function send_email_on_completed($form_id, $entry_id, $status) { if ($status == 'Completed') { $to = '[email protected]'; $subject = 'Entry Completed'; $message = "Entry ID: {$entry_id} has been marked as completed."; wp_mail($to, $subject, $message); } return $status; }
Block specific status change
Prevent the status of an entry from being changed to “Pending Review”.
add_action('gform_update_status', 'block_pending_review', 10, 3); function block_pending_review($form_id, $entry_id, $status) { if ($status == 'Pending Review') { // Get the current entry status $entry = GFAPI::get_entry($entry_id); $current_status = $entry['status']; return $current_status; } return $status; }