DRUPAL : creation + update user


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $newUser = array(
  3. 'name' => 'username',
  4. 'pass' => 'password', // note: do not md5 the password
  5. 'mail' => 'email address',
  6. 'status' => 1,
  7. 'init' => 'email address'
  8. );
  9. user_save(null, $newUser);
  10. ?>
  11.  
  12. And, here's how you can update an existing user:
  13.  
  14. <?php
  15. // load user object
  16. $existingUser = user_load('USERID');
  17.  
  18. // update some user property
  19. $existingUser->some_property = 'blah';
  20.  
  21. // save existing user
  22. user_save((object) array('uid' => $existingUser->uid), (array) $existingUser);
  23. ?>

URL: http://www.michaelphipps.com/how-create-users-programmatically-drupal-6x

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.