function commerce_addressbook_profile_create_access in Commerce Addressbook 7.2
Same name and namespace in other branches
- 7.3 commerce_addressbook.module \commerce_addressbook_profile_create_access()
Access callback: determine if the user can create a customer profile of the given type.
1 string reference to 'commerce_addressbook_profile_create_access'
- commerce_addressbook_menu in ./
commerce_addressbook.module - Implements hook_menu().
File
- ./
commerce_addressbook.module, line 118 - Defines addressbook functionality for customer profiles, allowing them to be reused and managed on a per-user basis.
Code
function commerce_addressbook_profile_create_access($account, $type) {
global $user;
// The addressbook is not enabled for this profile type.
if (!variable_get('commerce_customer_profile_' . $type . '_addressbook', FALSE)) {
return FALSE;
}
// The user has admin privileges, or is on his own pages.
if (user_access('administer commerce_customer_profile entities') || $user->uid == $account->uid) {
if (user_access('create commerce_customer_profile entities') || user_access('create commerce_customer_profile entities of bundle ' . $type)) {
return TRUE;
}
}
return FALSE;
}