Skip to content

Instantly share code, notes, and snippets.

@spivurno
Created September 12, 2012 23:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spivurno/3710746 to your computer and use it in GitHub Desktop.
Save spivurno/3710746 to your computer and use it in GitHub Desktop.
Gravity Wiz // Set Post Status by Field Value (Advanced)
/**
* Set Post Status by Field Value (Advanced)
* http://gravitywiz.com/2012/05/04/set-post-status-by-field-value-advanced/
*/
// update "3" to the ID of your form
add_filter('gform_post_data_3', 'gform_dynamic_post_status', 10, 3);
function gform_dynamic_post_status($post_data, $form, $entry) {
// update "5" to the ID of your custom post status field
if($entry[5]) {
switch($entry[5]) {
case 'Yes, please review my post.':
$post_data['post_status'] = 'pending';
break;
case 'No, please publish my post.':
$post_data['post_status'] = 'publish';
break;
}
}
return $post_data;
}
@spivurno
Copy link
Author

spivurno commented Jun 13, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment