Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gravity Flow - Assignee Field based access control via summary shortcode
<?php
add_filter( 'gravityflow_search_criteria_status', 'jo_status_scenario_search_criteria', 10, 1 );
function jo_status_scenario_search_criteria( $search_criteria ) {
if ( ! isset( $_SERVER['REQUEST_URI'] ) && strpos( strtolower( $_SERVER['REQUEST_URI'] ), '/status-check-64/' ) !== false ) {
return $search_criteria;
}
$current_user = wp_get_current_user();
if ( ! $current_user->exists() ) {
return $search_criteria;
}
$search_criteria['field_filters']['mode'] = 'any';
$search_criteria['field_filters'][] = array( 'key' => '6', 'value' => 'user_id|' . $current_user->ID );
return $search_criteria;
}
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.