Ali Nouman
This is a site slogan
  • Twitter
  • Linkedin
  • Home
  • About Me
  • Blog
  • Portfolio
  • Contact Me
  • Home

Programmatically assign user role in Drupal 7

06 Nov

Programmatically assign user role in Drupal 7

By alinouman Drupal, Drupal 7 0 Comments
You can use the following code for the adding roles programmatically in Drupal 7.
$role = user_role_load_by_name("my custom role");
user_multiple_role_edit(array($user->uid), 'add_role', $role->rid);

Share this post

Author

alinouman's picture

alinouman

Categories

  • .htaccess
  • ajax
  • angular
  • arrays
  • babel
  • Popular
  • Recent
  • Insert string at specified position| php
    Oct 24, 2016
  • Flexy Menu - Responsive Horizontal & Vertical Menu | Basic Aria
    Nov 03, 2016
  • Object Spread Operator | Cloning Object in Javascript
    Nov 16, 2016
  • Writing Custom Callback for ajax
    Feb 15, 2017
  • Anonymous function assigned to variable vs a named function.
    Feb 04, 2017
  • Check if object value exists and set new value for object key | Code optimization
    Feb 01, 2017
Get In Touch

Newsletter

Keep up on our always evolving product features and technology. Enter your e-mail and subscribe to our newsletter.

Contact Me

  • Skype: ali.nouman92

  • Email: [email protected]

Follow Me

  • Twitter
  • Linkedin

© Copyright 2020 by Ali Nouman

  • Contact