wc_shop_manager_has_capability( bool[] $allcaps, string[] $caps, array $args, WP_User $user )

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


Description Description


Parameters Parameters

$allcaps

(Required) Array of key/value pairs where keys represent a capability name and boolean values represent whether the user has that capability.

$caps

(Required) Required primitive capabilities for the requested capability.

$args

(Required) Arguments that accompany the requested capability check.

$user

(Required) The user object.


Top ↑

Return Return

(bool[])


Top ↑

Source Source

File: includes/wc-user-functions.php

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;
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.5.4 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.