Created
February 21, 2013 13:33
-
-
Save sirviejo/5004751 to your computer and use it in GitHub Desktop.
Create a Drupal user programatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); | |
$account->name = 'user_name'; | |
$account->pass = user_hash_password('password_string'); | |
$account->mail = 'user@mail.com'; | |
$account->status = 1; | |
// Add Role with rid 3 to this user | |
$roles = array('3' => true); | |
$account->roles = $roles; | |
$user = user_save($account); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment