Created
October 5, 2019 16:55
-
-
Save Idealien/c44010c956fcdb27ca746886146adfb1 to your computer and use it in GitHub Desktop.
Gravity Flow - Assignee Field based access control via summary shortcode
This file contains hidden or 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 | |
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