Created
March 17, 2020 03:59
-
-
Save zackkatz/b97572cc11fc09a5754e6af0561fd572 to your computer and use it in GitHub Desktop.
GravityView - Update Entry Approval Status using PHP
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
<?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