$new_user = array(
  'name' => 'Sg',
  'mail' => '[email protected]',
  'pass' => 'password123',
  'status' => 1,
  'field_custom_first_name' => array(LANGUAGE_NONE => array(array('value' =>'S'))), // This becomes $account->field_custom_first_name[LANGUAGE_NONE][0]['value']
  'field_custom_last_name' => array(LANGUAGE_NONE => array(array('value' => 'Doe'))),
  'access' => REQUEST_TIME,
  'roles' => array(), // No other roles than Authenticated
 //'roles' => array('10' => '10', '11' => '11'), // If you want to specify additional roles, the numbers are role_id's
user_save(NULL, $new_user);

I've seen this above code but where should I implement this code? I tried adding it and I got the error:

user_save() is an undefined function.

I just need to be able to login to the system as a super-admin.

  • where did you tried to add it? have you tried people > roles ? Commented Jun 3, 2016 at 11:51
  • Im sorry I could not login into the admin dashboard so I cant access people>roles.
    – ShanjayG
    Commented Oct 6, 2016 at 20:22

2 Answers 2


You have to create a super admin role(admin/people/permissions) and check all the boxes. And then you need to assign this role to the user.

  • The question here consists of 2 completely different questions (the last phrase in it is what is the 2nd question). This answer is, IMO, the "best" answer to most of the question, ie as in the title ... Commented Oct 22, 2016 at 8:43

I found what I was looking for. You can use drush to generate a one time login link which allows you to get into the system.

drush user-login or its alias drush uli

  • In fact, you can use drush uli [username] to login as any existing user in your website. Commented Oct 6, 2016 at 20:56
  • Cheers, didn't know that.
    – ShanjayG
    Commented Oct 6, 2016 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.