Description
The gform_post_status_options filter is used to add custom post statuses to the post status drop down on the Properties tab of post fields.
Usage
add_filter( 'gform_post_status_options', 'your_function_name' );
Parameters
| Parameter | Type | Description |
|---|---|---|
$post_status_options | array | Array containing the statuses of Draft, Pending Review, Published. |
Examples
1. Add a new status
This example adds a custom status to the drop down.
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;
}
2. Remove a status
This example removes Draft as being a selectable choice in the drop down.
add_filter( 'gform_post_status_options', 'remove_draft_post_status' );
function remove_draft_post_status( $post_status_options ) {
unset( $post_status_options['draft'] );
return $post_status_options;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This filter is located in form_detail.php.