Skip to content

Instantly share code, notes, and snippets.

@mgratch
Last active November 20, 2018 02:29
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 mgratch/8a17c7050eb4db270829 to your computer and use it in GitHub Desktop.
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.
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