0

If I have a role i.e. Member. How to set 'Member' as a default role for the users after they registered yourself ? Please help. Thanks

3

Can you not do this through Rules?

Event: After saving a new User account

Condition:

Action: Add User role > [account] - Member

  • May u pls tell me am I add Data Selector as "account" – Nishant Sep 22 '14 at 9:22
  • It should come as default, since the rule knows you are dealing with a User account, it should create a token for the new user account (are you using the Token module?) – Andrew Morris Sep 22 '14 at 9:25
  • Yes I just added Token... – Nishant Sep 22 '14 at 9:28
  • It should come as default then, if you've set it up as I've indicated (as I've just tested) it offers you the new users account as the default token. If not, go to the data selector, and select 'account (registered user)' – Andrew Morris Sep 22 '14 at 9:33
  • Its not working.. I just create a role i.e. Member, Create a rule & a/c & check through admin that what the role shows in front of that user but it doesn't show Member... – Nishant Sep 22 '14 at 9:38
3

Use Auto Assign Role module to set a default role at the time of user registration.

You can also use registration_role module to fulfill your requirement.

  • Thanks @Smalution.. Is there any other way to solve this without any module installation... – Nishant Sep 22 '14 at 8:05
  • Yes you can use your custom code using hook_user_insert. – DRUPWAY Sep 22 '14 at 8:08
  • I know about the custom hook.. Thanks @Smalution.. I think only through these two way, no any other way to solve this.. Am I right..??? – Nishant Sep 22 '14 at 8:12
  • Currently i do not know any other ways if you find any new way please update here. – DRUPWAY Sep 22 '14 at 8:18
  • 1
    Through Rules.. We can create "Member" as default role.. Its very easiest way... – Nishant Sep 22 '14 at 12:41
1

It is always recommended to use contributed module instead of writing a custom module if it is in stable release and fulfills your requirements. Auto Assign Role is exact solution of your problem.

  1. Install the module.
  2. Go to Configuration->People-> Auto Assign roles.
  3. Click on Automatic Assignment.
  4. Select your default role. (Member in your case)
  5. Click on save.

Bingo!

  • Thanks.. but what about existing users... If they are assigned as "authenticate" then how can I assign those as "Member" @Xeeshan – Nishant Sep 22 '14 at 12:38
  • For existing users, you can write a SQL script to update all existing users and assign them "Member" role as well. (User will have both roles member & authenticated Users). – Xeeshan Sep 22 '14 at 13:05
  • If you are don't want to write SQL script, you can use View Bulk Operation Module to update existing user roles using user interface. – Xeeshan Sep 22 '14 at 13:07
-2

click edit column on People page on specific user who will have role Member, and tick Memeber checkbox on that edit page.

  • Hey.. Please read question properly... I want that when user register urself.. Automatically assign them role as Member. – Nishant Sep 22 '14 at 7:57
  • sorry, my bad. probably you can implement hook_user_insert on your own custom registration module? – lyonsun Sep 22 '14 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.