function hook_uc_addresses_may_edit in Ubercart Addresses 6.2
Same name and namespace in other branches
- 7 uc_addresses.api.php \hook_uc_addresses_may_edit()
This hook allows you to prevent a certain address from being edited.
Don't use this hook if you want to prevent editing addresses for users with a certain role. You can use the permission settings for that.
If you want the address not to be edited return FALSE. Return TRUE in all other cases. WARNING: If you don't return TRUE, then no address may be edited.
Note that this hook is only invoked when permissions are checked and not when changes to an address are done programmatically.
Parameters
object $address_user: The owner of the address.
UcAddressesAddress $address: (optional) Address object.
object $account: The account to check access for.
Return value
boolean FALSE if the account may not edit the address or any address from the address user if no address is passed. TRUE otherwise.
1 invocation of hook_uc_addresses_may_edit()
- UcAddressesPermissions::canEditAddress in class/
UcAddressesPermissions.class.php - Check if the user can edit addresses of this user.
File
- ./
uc_addresses.api.php, line 321 - These hooks are invoked by the Ubercart Addresses module. @todo more documentation needed for hook_uc_addresses_field_handlers(). @todo Document the rest of the API.
Code
function hook_uc_addresses_may_edit($address_user, $address, $account) {
// Example: don't allow editing of default addresses.
if ($address instanceof UcAddressesAddress) {
if ($address
->isDefault('shipping') || $address
->isDefault('billing')) {
return FALSE;
}
}
// In all other cases, the address may be edited.
return TRUE;
}