Custom Email Addresses for Approving User Registration

The module relies on hook_mail() to send notification to the right administrator upon user registration to a selected section within the business. It utilizes Form API for providing a configuration form, this makes it possible to specify email addresses for user registration approval.

The site admin wants to delegate the responsibility of approving new user accounts to section managers, and to free the main site admin from receiving notifications about pending user registration. On the registration form users can choose which section of the business they are interested in. This was not possible without developing a custom module.

I met with the client, a Drupal specialist, discussed the project details, agreed best practice methods, and together we worked out a plan. He hired me for four days to work from their office on this module, and other Drupal tasks specific to their development tools and sites not mentioned here.

The module achieves the following:

  1. Allows certain administrators with specific role to be added via a simple form in the administration area.
  2. Sends notification to a selected administrator about pending user registration.
  3. Optionally disables the default Drupal admin notification about pending registration.

How Does the Module Work
Using Form API hooks the module builds a configuration form in the administration area for inputting data of certain administrators who have permission to approve pending user registration on the site, and extends Drupal's registration form by adding a selection list of sections in the company by implementing hook_form_FORM_ID_alter(). These sections will receive the pending approval notifications. Each administrator will receive a notification of pending user registration specific to her section. The administrator will not receive notifications about pending registrations in other sections.

The module also uses a hook to override the default behaviour of sending emails to the main site admin which can be disabled in the configuration page.

The module uses Profile hooks and several other Drupal core hooks like hook_mail() to send notification to the right administrator upon user registration.

It worth mentioning that Drupal 8 now makes it possible to allow more than one user email to receive notifications about user registration, much of the group effort and discussions can be found on this page. However, this module does more than that, and will send notification to the matching section of the business on all Drupal releases.