Hello,
I'm reading the Drupal API for creating a new user:
http://api.drupal.org/api/function/user_save/5
I have a few questions:
1) If I'm creating a new user, can I just set $account to be an empty array?
2) Which fields do I have to put in $array? Which fields are optional? I ran user_fields() to figure out what fields are available for $array. This is what I got:
User fields: uid, name, pass, mail, mode, sort, threshold, theme, signature, created, access, login, status, timezone, language, picture, init, data
I plan to include only name, pass, mail and login. Is it ok to exclude the others? I don't even know what some of the other fields are.
3) If I want to make a custom script that uses the Drupal API, which file do I need to include? I can't just include "user.module", clearly that file depends on others.
Thanks, Daniel.
Quoting Daniel Carrera daniel.carrera@zmsl.com:
Hello,
I'm reading the Drupal API for creating a new user:
http://api.drupal.org/api/function/user_save/5
I have a few questions:
If I'm creating a new user, can I just set $account to be an empty array?
Which fields do I have to put in $array? Which fields are optional? I
ran user_fields() to figure out what fields are available for $array. This is what I got:
User fields: uid, name, pass, mail, mode, sort, threshold, theme, signature, created, access, login, status, timezone, language, picture, init, data
I plan to include only name, pass, mail and login. Is it ok to exclude the others? I don't even know what some of the other fields are.
Sounds correct to me. I think you just need name, pass and mail.
- If I want to make a custom script that uses the Drupal API, which
file do I need to include? I can't just include "user.module", clearly that file depends on others.
You need to include "./includes/bootstrap.inc" and then execute drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL). The Drupal root directory must be your working directory before doing this.
-- Earnie http://r-feed.com Make a Drupal difference and review core patches.
Earnie Boyd wrote:
- If I want to make a custom script that uses the Drupal API, which
file do I need to include? I can't just include "user.module", clearly that file depends on others.
You need to include "./includes/bootstrap.inc" and then execute drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL). The Drupal root directory must be your working directory before doing this.
Ok, thanks. Can I put the program in a different directory and chdir() to the Drupal root?
Thanks Daniel.
Quoting Daniel Carrera daniel.carrera@zmsl.com:
Earnie Boyd wrote:
- If I want to make a custom script that uses the Drupal API, which
file do I need to include? I can't just include "user.module", clearly that file depends on others.
You need to include "./includes/bootstrap.inc" and then execute drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL). The Drupal root directory must be your working directory before doing this.
Ok, thanks. Can I put the program in a different directory and chdir() to the Drupal root?
Yes. I created a function for this I called drupalize that checks for the includes/bootstrap.php file else backs up another directory. I then know I'm in the root directory.
-- Earnie http://r-feed.com Make a Drupal difference and review core patches.