ACF_Location_Current_User_Role::matchpublicACF 5.9.0

Matches the provided rule against the screen args returning a bool result.

Method of the class: ACF_Location_Current_User_Role{}

No Hooks.

Returns

true|false.

Usage

$ACF_Location_Current_User_Role = new ACF_Location_Current_User_Role();
$ACF_Location_Current_User_Role->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_Role::match() code ACF 6.0.4

public function match( $rule, $screen, $field_group ) {

	// Get current user.
	$user = wp_get_current_user();
	if ( ! $user ) {
		return false;
	}

	// Check super_admin 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;
}