ACF_Location_Current_User::match
Matches the provided rule against the screen args returning a bool result.
Method of the class: ACF_Location_Current_User{}
No Hooks.
Returns
true|false.
Usage
$ACF_Location_Current_User = new ACF_Location_Current_User(); $ACF_Location_Current_User->match( $rule, $screen, $field_group );
- $rule(array) (required)
- The location rule.
- $screen(array) (required)
- The screen args.
- $field_group(array) (required)
- The field group settings.
Changelog
| Since 5.9.0 | Introduced. |
ACF_Location_Current_User::match() ACF Location Current User::match code ACF 6.0.4
public function match( $rule, $screen, $field_group ) {
switch ( $rule['value'] ) {
case 'logged_in':
$result = is_user_logged_in();
break;
case 'viewing_front':
$result = ! is_admin();
break;
case 'viewing_back':
$result = is_admin();
break;
default:
$result = false;
break;
}
// Reverse result for "!=" operator.
if ( $rule['operator'] === '!=' ) {
return ! $result;
}
return $result;
}