The gform_post_status_options filter allows you to modify the available post statuses in the post status dropdown on the Properties tab of post fields.
Usage
add_filter('gform_post_status_options', 'your_function_name');
Parameters
- $post_status_options (array): Array containing the statuses of Draft, Pending Review, and Published.
More information
See Gravity Forms Docs: gform_post_status_options
Examples
Add a new status
This example adds a custom status to the dropdown.
add_filter('gform_post_status_options', 'add_custom_post_status'); function add_custom_post_status($post_status_options) { $post_status_options['custom_status'] = 'My Custom Status'; return $post_status_options; }
Remove a status
This example removes Draft as a selectable choice in the dropdown.
add_filter('gform_post_status_options', 'remove_draft_status'); function remove_draft_status($post_status_options) { unset($post_status_options['draft']); return $post_status_options; }
Add multiple custom statuses
This example adds multiple custom statuses to the dropdown.
add_filter('gform_post_status_options', 'add_multiple_custom_statuses'); function add_multiple_custom_statuses($post_status_options) { $post_status_options['custom_status1'] = 'Custom Status 1'; $post_status_options['custom_status2'] = 'Custom Status 2'; return $post_status_options; }
Rename an existing status
This example renames the “Published” status to “Live”.
add_filter('gform_post_status_options', 'rename_published_status'); function rename_published_status($post_status_options) { $post_status_options['publish'] = 'Live'; return $post_status_options; }
Replace default statuses with custom statuses
This example replaces the default statuses with custom statuses.
add_filter('gform_post_status_options', 'replace_default_statuses'); function replace_default_statuses($post_status_options) { $new_statuses = array( 'custom_status1' => 'Custom Status 1', 'custom_status2' => 'Custom Status 2' ); return $new_statuses; }
Note: The code should be placed in the functions.php
file of your active theme.