Programmatically create users in Drupal 6.x
by Matt Danger on December 16, 2009
You can create a Drupal user by sending user_save() a null parameter and an array of user information. You can also assign a role by setting an array that is keyed with the role ID (rid). This can be obtained by calling user_roles() as shown in the example below.
// Get an array of roles $roles = user_roles(); // Basic account information $user = array( 'name' => 'Some User', 'pass' => 'some_password', 'mail' => 'user@example.com', 'status' => 1, 'init' => 'user@example.com', 'roles' => array(array_search('some_role', $roles) => 1), ); // See if the user exists by calling Drupal's user_load() $existing_user = user_load(array('name' => $user['name'])); if (!$existing_user->uid) { // Save the user $user = user_save(NULL, $user); }
2 comments for this entry:
July 22nd, 2010 on 5:25 am
Buy:Benicar.Lipitor.Acomplia.Wellbutrin SR.SleepWell.Seroquel.Buspar.Zetia.Aricept.Nymphomax.Female Pink Viagra.Ventolin.Female Cialis.Lipothin.Prozac.Zocor.Cozaar.Lasix.Amoxicillin.Advair….
August 29th, 2010 on 10:11 pm
Covers http://islidersep.BESTPARTSPLUS.INFO/tag/Truck+Headrest+Covers/ : Headrest…
Covers…