gravityflow_permission_granted_entry_detail

Description

The gravityflow_permission_granted_entry_detail filter allows the permission check to be overridden for the workflow entry detail page.

Parameters

  • $permission_granted bool
    Whether permission is granted to open the entry.
  • $entry Array
    The current entry array.
  • $current_step Gravity_Flow_Step
     Null or the current step.
ParameterTypeDefinition
$permission_grantedBooleanWhether permission is granted to open the entry.
$entryEntryThe current entry array.
$current_stepStepNull or the current step.

Examples

Override display permissions based on current user in an assignee field

By default, a user that has previous/future actions on a workflow that is not an administrator or the entry submitter can only see the entry via the inbox. This filter will let the current user see any entries where they are defined as an assignee field value.

add_filter( 'gravityflow_permission_granted_entry_detail', 'jo_status_scenario_permissions_check', 10, 4 );
function jo_status_scenario_permissions_check( $permission_granted, $entry, $form, $current_step ) {

    if ( ! isset( $_SERVER['REQUEST_URI'] ) && strpos( strtolower( $_SERVER['REQUEST_URI'] ), '/status-check-64/' ) !== false ) {
        return $permission_granted;
    }

    if ( $form['id'] != '64' ) {
        return $permission_granted;
    }

    $current_user = wp_get_current_user();
    if ( ! $current_user->exists() ) {
        return $permission_granted;
    }

    if ( $entry['6'] == 'user_id|' . $current_user->ID ) {
        return true;
    }

    return $permission_granted;
}

The above filter is intended to be used on a page with the Gravity Flow Shortcode for specific form in status view – [gravityflow page=”status” form=”64″] that would have also used gravityflow_search_criteria_status filter in a similar setup to override which entries the assignee sees in their status list.

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?