i am writing a module that form user registration form, how do i find out what the user id is when site admin create a user account?
i tryed global $user and useing $user->uid but that gives me the admin uid not the newly created account id.

Comments

nevets’s picture

You could implement hook_user_insert and look at $account.

tchivoan1972’s picture

how would you get values from form elements that you added to the registration form.

bboldi’s picture

As nevets said, you can use hook_user_insert hook to catch user insertion, and use variables. First you need to create a custom module ( http://drupal.org/developing/modules ) then implement the hook_user_insert ( http://api.drupal.org/api/drupal/modules--user--user.api.php/function/ho... ) , and every time a user gets added to your system, the user_insert hook in your module will be executed by drupal, and the following data will be passed to your function:

$edit The array of form values submitted by the user. - the form values that you've been asking for
$account The user object on which the operation is being performed. - $account->uid should contain the user id
$category The active category of user information being edited.

Hope it helps !

tchivoan1972’s picture

ok thanks, another question how can i get drupal to display the content of the array $edit or $account? i tried using var_dump and print_r but doesn't seem to do anything.

nevets’s picture

If you have the devel module installed you can use dsm($some_variable).

Without devel I use drupal_set_message('<pre>' . print_r($some_variable, TRUE) . '</pre>');