Last active
November 20, 2018 02:29
-
-
Save mgratch/8a17c7050eb4db270829 to your computer and use it in GitHub Desktop.
This will update the post status from pending to publish or vice versa when approved/dissaproved using GravityView.
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
add_action('gravityview/approve_entries/approved','publish_pending_testimonial'); | |
function publish_pending_testimonial($entry_id){ | |
$entry = RGFormsModel::get_lead($entry_id); | |
if ($entry['post_id'] != null){ | |
$my_post = array( | |
'ID' => $entry['post_id'], | |
'post_status' => 'publish' | |
); | |
// Update the post into the database | |
wp_update_post( $my_post ); | |
} | |
} | |
add_action('gravityview/approve_entries/disapproved','unpublish_pending_testimonial'); | |
function unpublish_pending_testimonial($entry_id){ | |
$entry = RGFormsModel::get_lead($entry_id); | |
if ($entry['post_id'] != null){ | |
$my_post = array( | |
'ID' => $entry['post_id'], | |
'post_status' => 'pending' | |
); | |
// Update the post into the database | |
wp_update_post( $my_post ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment