Hi,

I want to assign a standard role to every new registered user. Has anyone done this before?

Regards

Bas

Comments

sami_k’s picture

It's not that hard at all, it requires you to use the user hook (look it up drupal.org as I need to go to bed)... When a new user is created you simply insert the rid into the user_role table using the uid of the created user. There may be an easier way to do it, and if there is I am sure someone will chime in any moment now.

--
Please read the handbook, search the forums, then ask...
http://drupal.etopian.net (Consulting, Development, and Hosting)

kbahey’s picture

Not sure if you thought about this or not, but anyways: The authenticated user is always an assigned role by default, so you can tweek the permissions of that role to your liking, and it will be applied automatically.

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

bluecobalt’s picture

Is there a way to do this in 4.6.3? Or would a module need to be created to do this?

----
Blue Cobalt
Theurgy Foundation
http://www.theurgyfoundation.org

Blue Cobalt
http://livingparadise.org
Conscious living for a better world.

bluecobalt’s picture

bump.

We need to have the ability for a person to choose a designated group upon registration (such as "volunteer"), and be automatically assigned to that role. Does anyone have any ideas on how best to accomplish this?

---
Blue Cobalt
Theurgy Foundation
http://www.theurgyfoundation.org

Blue Cobalt
http://livingparadise.org
Conscious living for a better world.

pamphile’s picture

i'm also interested in this...

kbahey’s picture

Any solution has to make sure that this is done right. Privileged roles (e.g. admin, moderator) should NOT be assigned automatically.

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

adshill’s picture

If you look in the file "user.module" at line 898 you will see the line:

function _user_authenticated_id() {
return db_result(db_query("SELECT rid FROM {role} WHERE name = 'authenticated user'"));
}

Simply change "authenticated user" to the Role name that you would like to default at registration and save the file. Bingo.

pamphile’s picture

mattmackenzie’s picture

logintoboggan allows you to put unverified people into a particular role, for cases where you allow your users to interact with your site before making sure they've provided a valid email address.

I don't think it solves this particular problem.

MartinGeber’s picture

I also need this feature, as I made DokuWiki use the User Data from Drupals Database for Authentification, but DokuWiki needs a Role so it knows what rights the user has. Drupal's standard role (authentificated user) is not in the role table of the database, so that's the problem why I need to make another role and assign it to every new user.

Regards, MG

greggles’s picture

This problem was solved in a comment on another thread: http://drupal.org/node/28379#comment-132430 I succesfully used a modified version of that snippet for a recent site.

If you need assistance creating the module or using that snippet consider the guide to module developers or hiring someone to write it for you.

Regards,
Greg

--
Growing Venture Solutions
Drupal Implementation and Support in Denver, CO

mitchell’s picture

Rules is a great solution if you don't want to write your own module.

thinkbig’s picture

There's a 5x and 6x module specifically for this— AutoAssignRole:

http://drupal.org/project/autoassignrole