gravityflow_permission_granted_entry_detail

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

Parameters

Parameter Type Definition
$permission_granted Boolean
Whether permission is granted to open the entry.
$entry Array The current entry array.
$current_step null|Gravity_Flow_Step  Null or the current step.

Examples

Example 1 - 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 should be placed in the functions.php file of your active theme or in a custom functions plugin.