ACF_Location_Current_User_Role::match
Matches the provided rule against the screen args returning a bool result.
Метод класса: ACF_Location_Current_User_Role{}
Хуков нет.
Возвращает
boolean.
Использование
$ACF_Location_Current_User_Role = new ACF_Location_Current_User_Role(); $ACF_Location_Current_User_Role->match( $rule, $screen, $field_group );
- $rule(массив) (обязательный)
- The location rule.
- $screen(массив) (обязательный)
- The screen args.
- $field_group(массив) (обязательный)
- The field group settings.
Список изменений
| С версии 5.9.0 | Введена. |
Код ACF_Location_Current_User_Role::match() ACF Location Current User Role::match ACF 6.8.8
public function match( $rule, $screen, $field_group ) {
// Get current user.
$user = wp_get_current_user();
if ( ! $user ) {
return false;
}
// Check super_admin value.
$rule_value = $rule['value'] ?? '';
if ( $rule_value == 'super_admin' ) {
$result = is_super_admin( $user->ID );
// Check role.
} else {
$result = in_array( $rule_value, $user->roles );
}
// Reverse result for "!=" operator.
if ( ( $rule['operator'] ?? '' ) === '!=' ) {
return ! $result;
}
return $result;
}