Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Set Post Status by Product Field Value
// 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 "6" to the ID of your custom post status field
if($entry[6]) {
$values = explode('|', $entry[6]);
switch($values[0]) {
case 'Basic Package':
$post_data['post_status'] = 'draft';
case 'Premium Package':
$post_data['post_status'] = 'publish';
return $post_data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment