Automattic\WooCommerce\Internal\POS

Capabilities::has_pos_access │ public static │ WC 11.0.0

Whether a user has any POS access at all.

True if the user holds at least one of the known woocommerce_pos_* capabilities (those in all_pos_capabilities()). This is the single authorization signal for POS access: neither a WP role nor any meta value grants it on its own. The any-cap definition fits both fixed presets (each preset's caps granted as a bundle) and a future granular model (individual woocommerce_pos_* caps assigned without a baseline cap).

Reads the resolved capability map (WP_User::$allcaps) directly rather than looping over user_can(). user_can() re-runs map_meta_cap() and fires the user_has_cap filter on every call, so the loop would dispatch that machinery once per POS cap; an $allcaps lookup is a plain array check per cap.

Reading $allcaps also scopes access to caps the user actually holds: unlike user_can(), it does not honor the multisite super-admin grant, which has_cap() applies as a runtime gate rather than storing in $allcaps. A super admin therefore does not implicitly count as POS staff — they need an explicit woocommerce_pos_* cap like anyone else.

Method of the class: Capabilities{}

No Hooks.

Returns

bool.

Usage

$result = Capabilities::has_pos_access( $user_id ): bool;
$user_id(int) (required)
Target user.

Changelog

Since 11.0.0 Introduced.

Capabilities::has_pos_access() code WC 11.1.2

public static function has_pos_access( int $user_id ): bool {
	if ( $user_id <= 0 ) {
		return false;
	}

	$user = get_userdata( $user_id );
	if ( ! $user ) {
		return false;
	}

	foreach ( self::all_pos_capabilities() as $cap ) {
		if ( ! empty( $user->allcaps[ $cap ] ) ) {
			return true;
		}
	}
	return false;
}