登录站点

用户名

密码

注册

xiaoluan0318

xiaoluan0318的日志

xiaoluan0318的主页 | 查看全部日志
查看日志|返回日志列表

How To Create Users Programmatically In Drupal 6.x

标签Create  Drupal  How  Users  2009-11-21 00:23

Here's a quick code snippet you can use to programmatically create new users in Drupal 6.x:

<?php
$newUser = array(
'name' => 'username',
'pass' => 'password', // note: do not md5 the password
'mail' => 'email address',
'status' => 1,
'init' => 'email address'
);
user_save(null, $newUser);
?>

And, here's how you can update an existing user:

<?php
// load user object
$existingUser = user_load('USERID');

// update some user property
$existingUser->some_property = 'blah';

// save existing user
user_save((object) array('uid' => $existingUser->uid), (array) $existingUser);
?>
分享 88 次阅读 | 0 个评论

留下脚印

评论