Created
September 12, 2012 23:32
-
-
Save spivurno/3710757 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set Post Status by Product Field Value | |
* 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 "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'; | |
break; | |
case 'Premium Package': | |
$post_data['post_status'] = 'publish'; | |
break; | |
} | |
} | |
return $post_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-set-post-status-by-product-field-value.php