function hook_user_role_presave

hook_user_role_presave($role)

Act on a user role being inserted or updated.

Modules implementing this hook can act on the user role object before it has been saved to the database.

Parameters

$role: A user role object.

See also

hook_user_role_insert()

hook_user_role_update()

Related topics

File

modules/user/user.api.php, line 408
Hooks provided by the User module.

Code

function hook_user_role_presave($role) {
  // Set a UUID for the user role if it doesn't already exist
  if (empty($role->uuid)) {
    $role->uuid = uuid_uuid();
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_role_presave/7.x