Add rol to a drupal user
This is an example of how we can add a new rol to a drupal user:
// First load the actual drupal user
global $user;
// The name of the role to add.
$role_name = 'graphic_designer';
if ($role = user_role_load_by_name($role_name)) {
user_multiple_role_edit(array($user->uid), 'add_role', $role->rid);
}
Written by Dennis Ruiz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Drupal
Authors
Related Tags
#drupal
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#