Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Created March 17, 2020 03:59
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 zackkatz/b97572cc11fc09a5754e6af0561fd572 to your computer and use it in GitHub Desktop.
Save zackkatz/b97572cc11fc09a5754e6af0561fd572 to your computer and use it in GitHub Desktop.
GravityView - Update Entry Approval Status using PHP
<?php
// Check to make sure GravityView is loaded
if ( ! class_exists( 'GravityView_Entry_Approval' ) ) {
return;
}
/**
* There are three options that should be used when updating entry approval statuses:
* GravityView_Entry_Approval_Status::APPROVED - Approved/Accepted entries
* GravityView_Entry_Approval_Status::DISAPPROVED - Disapproved/Rejected entries
* GravityView_Entry_Approval_Status::UNAPPROVED - Unapproved/Not Reviewed entries
*/
$updated = GravityView_Entry_Approval::update_approved( $entry_id, GravityView_Entry_Approval_Status::APPROVED );
if ( ! $updated ) {
echo 'There are a few reasons this might not have worked. GFAPI class isn\'t found, invalid approval status, entry not found for that ID, or updating the entry in the database failed.';
} else {
echo 'Thanks for reading!';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment