[development] Assigning user to roles programatically -- what finally worked

Adrian Rossouw adrian at bryght.com
Mon Jan 30 11:30:52 UTC 2006

On 30 Jan 2006, at 12:39 AM, Rob Thorne wrote:

>    * On $op == 'insert',  Adrian approach doesn't work, because
>      user_save has already done everything it will ever do with the
>      user_roles table.  So in that case, you need to do what Khalid
>      suggests:  INSERT a row into the user_roles table.
Yup. you're correct.

I tracked through the code and found out that userapi $op='insert' is  
called after
the user_save function. Same with node.

Reason being user_save and node_save is where they get the $uid /  
$nid, which
is needed for saving the rest of the data.

Love these fun inconsistencies =)

Adrian Rossouw
Drupal developer and Bryght Guy
http://drupal.org | http://bryght.com

More information about the development mailing list