[support] Drupal API - Create user

Earnie Boyd earnie at users.sourceforge.net
Thu Dec 11 20:06:48 UTC 2008


Quoting Daniel Carrera <daniel.carrera at 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:
>
> 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.
>

Sounds correct to me. I think you just need name, pass and mail.

> 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.
>

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.

-- http://for-my-kids.com/  -- http://give-me-an-offer.com/



More information about the support mailing list