i was trying to create a new user Programmatically in drupal 6.22 but i can't seem to get it working. I need to make a web service that can do a few things, one being create a new user. This webservice is going to be consumed by a mobile device. I was just trying to test the user_save from outside drupal in just a simple php file and it doesn't seem to work. I just need to know what i'm doing wrong.
Here is my code
<?php
require_once(includes/bootstrap.inc);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Get an array of roles
$roles = user_roles();
//Basic account information
$user = array(
'name' => 'username',
'pass' => 'Password',
'mail' => 'email',
'status' => 1,
'init' => 'email',
'roles' => array(array_search('authenticated user', $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);
}
?>
EDIT: Added the drupal_bootstrap, still not working for me.