[development] Assigning user to roles programatically

Rob Thorne rob at torenware.com
Fri Jan 27 02:14:21 UTC 2006


I'm looking for some way to assign a user to a role programatically.  
You'd think this would be easy to do, but it isn't:  I tried just about 
every drupal hook you can think of to hook add this to the "user add" 
and "user edit" screens, and nothing worked.  The problem was that 
node_save really really really wanted to get in there last, and I never 
found a way to get around this.  I even tried to stamp the fields into 
the database.  No use.  node_save just went in at the end of the request 
and changed it back for me :-(

Does anyone know how to coerce Drupal 4.6 into doing this?  Or sweet 
talk it into this?  It would be nice if there was an API for this, but 
AFAIK there isn't.  What hook should I use, and which 2x4 do I need to 
apply?

Thanks,
Rob Thorne
Torenware Networks


More information about the development mailing list