wc_shop_manager_has_capability()WC 3.5.4

Safe way of allowing shop managers restricted capabilities that will remove access to the capabilities if WooCommerce is deactivated.

No Hooks.

Return

true|false[].

Usage

wc_shop_manager_has_capability( $allcaps, $caps, $args, $user );
$allcaps(bool[]) (required)
Array of key/value pairs where keys represent a capability name and boolean values represent whether the user has that capability.
$caps(string[]) (required)
Required primitive capabilities for the requested capability.
$args(array) (required)
Arguments that accompany the requested capability check.
$user(WP_User) (required)
The user object.

Changelog

Since 3.5.4 Introduced.

wc_shop_manager_has_capability() code WC 9.4.2

function wc_shop_manager_has_capability( $allcaps, $caps, $args, $user ) {

	if ( wc_user_has_role( $user, 'shop_manager' ) ) {
		// @see wc_modify_map_meta_cap, which limits editing to customers.
		$allcaps['edit_users'] = true;
	}

	return $allcaps;
}