GravityView  2.1.1
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Static Private Member Functions
GravityView_Entry_Approval Class Reference

If this file is called directly, abort. More...

Public Member Functions

 __construct ()
 
 _trigger_notifications ( $entry_id=0)
 Passes approval notification and action hook to the send_notifications method. More...
 
 after_submission ( $entry, $form)
 Update the is_approved meta whenever the entry is submitted (and it contains a User Opt-in field) More...
 
 after_update_entry_update_approved_meta ( $form, $entry_id=NULL)
 Update the is_approved meta whenever the entry is updated. More...
 
 ajax_update_approved ()
 Approve/Disapprove entries using the × or ✓ icons in the GF Entries screen. More...
 

Static Public Member Functions

static add_approval_notification_events ( $notification_events=array(), $form=array())
 Adds entry approval status change custom notification events. More...
 
static autounapprove ( $form, $entry_id, $edit, $gv_data)
 Maybe unapprove entry on edit. More...
 
static get_entry_status ( $entry, $value_or_label='label')
 Get the approval status for an entry. More...
 
static update_approved ( $entry_id=0, $approved=2, $form_id=0, $approvedcolumn=0)
 update_approved function. More...
 
static update_bulk ( $entries=array(), $approved, $form_id)
 Process a bulk of entries to update the approve field/property. More...
 

Data Fields

const meta_key = 'is_approved'
 

Private Member Functions

 _send_notifications ( $entry_id='', $event='')
 Passes along notification triggers to GFAPI::send_notifications() More...
 
 add_hooks ()
 Add actions and filters related to entry approval. More...
 

Static Private Member Functions

static add_approval_status_updated_note ( $entry_id, $approved=0)
 Add a note when an entry is approved. More...
 
static get_approved_column_input_label ( $form, $approved_column)
 Get the value for the approved field checkbox. More...
 
static update_approved_meta ( $entry_id, $status, $form_id=0)
 Update the is_approved entry meta value. More...
 

Detailed Description

If this file is called directly, abort.

Generate linked list output for a list of entries.

Since
1.18

Definition at line 23 of file class-gravityview-entry-approval.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Definition at line 30 of file class-gravityview-entry-approval.php.

References add_hooks().

Member Function Documentation

◆ _send_notifications()

_send_notifications (   $entry_id = '',
  $event = '' 
)
private

Passes along notification triggers to GFAPI::send_notifications()

Since
2.1
Parameters
int$entry_idID of entry being updated
string$eventHook that triggered the notification. This is used as the key in the GF notifications array.
Returns
void

Definition at line 88 of file class-gravityview-entry-approval.php.

References $entry, GV\$form, and gravityview().

Referenced by _trigger_notifications().

◆ _trigger_notifications()

_trigger_notifications (   $entry_id = 0)

Passes approval notification and action hook to the send_notifications method.

See also
GravityView_Entry_Approval::send_notifications()

Definition at line 74 of file class-gravityview-entry-approval.php.

References _send_notifications().

◆ add_approval_notification_events()

static add_approval_notification_events (   $notification_events = array(),
  $form = array() 
)
static

Adds entry approval status change custom notification events.

Since
2.1
Parameters
array$notification_eventsThe notification events.
array$formThe current form.

Definition at line 115 of file class-gravityview-entry-approval.php.

◆ add_approval_status_updated_note()

static add_approval_status_updated_note (   $entry_id,
  $approved = 0 
)
staticprivate

Add a note when an entry is approved.

See also
GravityView_Entry_Approval::update_approved
Since
1.18
Parameters
int$entry_idGravity Forms entry ID
int$approvedApproval status
Returns
false|int|WP_Error Note ID if successful; WP_Error if error when adding note, FALSE if note not updated because of gravityview/approve_entries/add-note filter or GravityView_Entry_Notes class not existing
Runs Filter:
gravityview/approve_entries/add-note Add a note when the entry has been approved or disapproved?
Since
1.16.3
Parameters
bool$add_noteTrue: Yep, add that note! False: Do not, under any circumstances, add that note!

Definition at line 428 of file class-gravityview-entry-approval.php.

References $entry, $form_id, GravityView_Entry_Notes\add_note(), GravityView_Entry_Approval_Status\APPROVED, GravityView_Entry_Approval_Status\DISAPPROVED, GravityView_Entry_Approval_Status\is_valid(), GravityView_Entry_Approval_Status\maybe_convert_status(), and GravityView_Entry_Approval_Status\UNAPPROVED.

◆ add_hooks()

add_hooks ( )
private

Add actions and filters related to entry approval.

Returns
void

Definition at line 39 of file class-gravityview-entry-approval.php.

Referenced by __construct().

◆ after_submission()

after_submission (   $entry,
  $form 
)

Update the is_approved meta whenever the entry is submitted (and it contains a User Opt-in field)

Since
1.16.6
2.0.14 Set the default approval is_approved value upon submission
Parameters
$entryarray Gravity Forms entry object
$formarray Gravity Forms form object
Runs Filter:
gravityview/approve_entries/after_submission/default_status Modify the default approval status for newly submitted entries
Since
2.0.14
Parameters
int$default_statusSee GravityView_Entry_Approval_Status() for valid statuses.

Definition at line 246 of file class-gravityview-entry-approval.php.

References $entry, GV\$form, after_update_entry_update_approved_meta(), gravityview(), GravityView_Entry_Approval_Status\is_valid(), and GravityView_Entry_Approval_Status\UNAPPROVED.

◆ after_update_entry_update_approved_meta()

after_update_entry_update_approved_meta (   $form,
  $entry_id = NULL 
)

Update the is_approved meta whenever the entry is updated.

Since
1.7.6.1 Was previously named update_approved_meta
Parameters
array$formGravity Forms form array
int$entry_idID of the Gravity Forms entry
Returns
void

If the form doesn't contain the approve field, don't assume anything.

Definition at line 279 of file class-gravityview-entry-approval.php.

References $entry, GV\$form, $value, GravityView_Entry_Approval_Status\APPROVED, GravityView_Entry_Approval_Status\DISAPPROVED, and GV\get().

Referenced by after_submission().

◆ ajax_update_approved()

ajax_update_approved ( )

Approve/Disapprove entries using the × or ✓ icons in the GF Entries screen.

wp_send_json_error() wp_send_json_success()

Expects a $_POST request with the following $_POST keys and values:

array $_POST { int $form_id ID of the form connected to the entry being updated string|int $entry_slug The ID or slug of the entry being updated string $approved The value of the entry approval status {

See also
GravityView_Entry_Approval_Status::is_valid() } }
Returns
void Prints result using wp_send_json_success() and wp_send_json_error()

Definition at line 167 of file class-gravityview-entry-approval.php.

References $current_status, $form_id, Utils\_POST(), GVCommon\get_entry_id(), gravityview(), GVCommon\has_cap(), and GravityView_Entry_Approval_Status\is_valid().

◆ autounapprove()

static autounapprove (   $form,
  $entry_id,
  $edit,
  $gv_data 
)
static

Maybe unapprove entry on edit.

Called from gravityview/edit_entry/after_update

Parameters
array$formGravity Forms form array
string$entry_idNumeric ID of the entry that was updated
GravityView_Edit_Entry_Render$editThis object
GravityView_View_Data$gv_dataThe View data
Returns
void

Definition at line 654 of file class-gravityview-entry-approval.php.

References GV\$form, View\by_id(), GVCommon\has_cap(), and GravityView_Entry_Approval_Status\UNAPPROVED.

◆ get_approved_column_input_label()

static get_approved_column_input_label (   $form,
  $approved_column 
)
staticprivate

Get the value for the approved field checkbox.

When approving a field via the entry meta, use the correct value for the new approved column input

Since
1.19
Parameters
array | int$formForm ID or form array
string$approved_columnApproved column field ID
Returns
string|null

Definition at line 526 of file class-gravityview-entry-approval.php.

References $field, GV\$form, and gravityview_get_field().

◆ get_entry_status()

static get_entry_status (   $entry,
  $value_or_label = 'label' 
)
static

Get the approval status for an entry.

Since
1.18 GVCommon::get_entry_id() Accepts entry slug or entry ID
Parameters
array | int | string$entryEntry array, entry slug, or entry ID
string$value_or_label"value" or "label" (default: "label")
Returns
bool|string Return the label or value of entry approval

Definition at line 136 of file class-gravityview-entry-approval.php.

References $entry, GVCommon\get_entry_id(), GravityView_Entry_Approval_Status\get_label(), and GravityView_Entry_Approval_Status\maybe_convert_status().

Referenced by GravityView_Admin_ApproveEntries\add_entry_approved_hidden_input(), and GravityView_Field_Is_Approved\custom_merge_tags().

◆ update_approved()

static update_approved (   $entry_id = 0,
  $approved = 2,
  $form_id = 0,
  $approvedcolumn = 0 
)
static

update_approved function.

Since
1.18 Moved to GravityView_Entry_Approval class

public

Parameters
int$entry_id(default: 0)
int$approved(default: 2)
int$form_id(default: 0)
int$approvedcolumn(default: 0)
Returns
boolean True: It worked; False: it failed

Destroy the cache for this form

See also
class-cache.php
Since
1.5.1

Definition at line 363 of file class-gravityview-entry-approval.php.

References $entry, $form_id, gravityview(), GravityView_Entry_Approval_Status\is_valid(), and GravityView_Entry_Approval_Status\maybe_convert_status().

Referenced by GravityView_Admin_ApproveEntries\update_approved().

◆ update_approved_meta()

static update_approved_meta (   $entry_id,
  $status,
  $form_id = 0 
)
staticprivate

Update the is_approved entry meta value.

Since
1.7.6.1 after_update_entry_update_approved_meta was previously to be named update_approved_meta
1.17.1 Added $form_id parameter
Parameters
int$entry_idID of the Gravity Forms entry
string$statusString whether entry is approved or not. 0 for not approved, Approved for approved.
int$form_idID of the form of the entry being updated. Improves query performance.
Returns
void
Runs Actions:
gravityview/approve_entries/updated Triggered when an entry approval is updated
Since
1.7.6.1
Parameters
int$entry_idID of the Gravity Forms entry
string | int$statusString whether entry is approved or not. See GravityView_Entry_Approval_Status for valid statuses.
Runs Actions:
gravityview/approve_entries/{$action} Triggered when an entry approval is set. {$action} can be 'approved', 'unapproved', or 'disapproved' Note: If you want this to work with Bulk Actions, run in a plugin rather than a theme; the bulk updates hook runs before themes are loaded.
Since
1.7.6.1
1.18 Added "unapproved"
Parameters
int$entry_idID of the Gravity Forms entry

Definition at line 556 of file class-gravityview-entry-approval.php.

References $field, GV\$form, $form_id, GVCommon\get_form(), GravityView_Entry_Approval_Status\get_key(), gravityview(), GravityView_Entry_Approval_Status\is_valid(), and GravityView_Entry_Approval_Status\maybe_convert_status().

◆ update_bulk()

static update_bulk (   $entries = array(),
  $approved,
  $form_id 
)
static

Process a bulk of entries to update the approve field/property.

Since
1.18 Moved to GravityView_Entry_Approval
1.18 Made public

public

Parameters
array | boolean$entriesIf array, array of entry IDs that are to be updated. If true: update all entries.
int$approvedApproved status. If 0: unapproved, if not empty, Approved
int$form_idThe Gravity Forms Form ID
Returns
boolean|null True: successfully updated all entries. False: there was an error updating at least one entry. NULL: an error occurred (see log)

Definition at line 316 of file class-gravityview-entry-approval.php.

References $entries, $form_id, gravityview(), GVCommon\has_cap(), and GravityView_Entry_Approval_Status\is_valid().

Referenced by GravityView_Admin_ApproveEntries\process_bulk_action().

Field Documentation

◆ meta_key

const meta_key = 'is_approved'

The documentation for this class was generated from the following file: