3

I have two roles on my site:

  • Visitor, the normal user who can register on our site without any admin approval procedure
  • Business role, the business user who can register and add their business to our site, with admin approval.

Can anyone suggest how I can allow registration based on role, so that one requires approval, and the other doesn't?

Also there are two different registration links for users whether they want to register as normal or business user; based on which link the user click, the registration process will take place.

2
  • 2
    A similar question, drupal.stackexchange.com/questions/27525/…. In your case you can replace register?code=promo1 as register?user_type= business or normal and change url according to that Nov 1, 2012 at 11:53
  • @AnoopJoseph, can u please be more specific? any module is available to create multiple registration form?
    – Cool
    Jun 17, 2014 at 9:40

4 Answers 4

4

I would recommend that you have all users register on the same page, and have "business" users register for the right to add businesses using either the Apply for Role module or Organic Groups. Note that Organic Groups will allow you to put a checkbox on the registration page, so business users could check the appropriate request checkbox as they sign up. An admin would have to approve their request to join the "business" group.

2

Check the Registration Role with Approval module, some details about it (from its project page):

This module lets administrator to select roles that will be available for selection on registration form. It also allows to select which roles needs admin approval.

During registration user will be presented with optional checkboxes where he can select a role. If role needs admin approval, user account will be blocked until approved by admin. Email will be sent to administrator with roles that are requested and username of user who request it.

1

Another solution for this is the (fairly new) Select registration roles module. Some more details about it (from its project page):

The Select Registration Roles module adds a role field on the user registration form. Admin can configure roles to be displayed on the registration form as, and can set roles which require admin approval.

Here is a screenprint of it:

enter image description here

Obviously, by using this module, you wouldn't need 2 registrations links anymore (which should reduce the number of registration errors also, because of using the wrong registration link ...).

Note: a stable release is available for either D7 or D8.

1

If you have the user account creation form but using the Multiple Registration module to update its path, you can use hook_user_presave() to update the status of the user with the required role:

function MY_MODULE_user_presave(Drupal\Core\Entity\EntityInterface $user) {
  $roles = $user->getRoles();
  if (in_array('ROLE_MACHINE_NAME', $roles)) {
    $user->status->value = 0;
  }
  elseif (in_array('commerce_marketplace_admin', $roles)) {
    $user->status->value = 0;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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