Skip to content

Instantly share code, notes, and snippets.

@shamsher327
Created February 5, 2019 10:38
Show Gist options
  • Save shamsher327/27d84b1b4ba2d1bfa6829adb51671341 to your computer and use it in GitHub Desktop.
Save shamsher327/27d84b1b4ba2d1bfa6829adb51671341 to your computer and use it in GitHub Desktop.
User load and crate role
$user = \Drupal\user\Entity\User::load(2131);
$user->addRole('administrator');
$user->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment