In my plugin, I am checking to see if the current logged in user has permission to save a commerce product.

$user = craft()->userSession->getUser();
if (craft()->userPermissions->doesUserHavePermission($user->id, 'ManageClothingProducts')) {
    // yes permission
} else {
  // no permission

However, it seems I'm always getting into the else.

The commerce docs mention this:

Manage [type] products

Maybe I'm not using the correct syntax? I'm only using the clothing products as an example. Ultimately I'll be checking for my own products.

Thank you for any suggestions!

1 Answer 1


The correct permission key is:


for example:


Your code would therefore be:

$user = craft()->userSession->getUser();
if (craft()->userPermissions->doesUserHavePermission($user->id, 'commerce-manageProductType:2')) {
    // yes permission
} else {
  // no permission

Or you could use UserSessionService::checkPermission(), which is a shortcut for checking permissions for the currently logged-in user:

if (craft()->userSession->checkPermission('commerce-manageProductType:2')
  • Thanks Luke & Brandon! It's interesting though, when I am logged in as the site admin, this works: craft()->userSession->checkPermission('commerce-manageProductType:1'). However, this says I do not have permission craft()->userPermissions->doesUserHavePermission($user->id, 'commerce-manageProductType:1')
    – Damon
    Commented Aug 29, 2016 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.