Drupal is a registered trademark of Dries Buytaert

rare

No security coverage
View on drupal.org

Automatically assign Drupal roles to new users at the point of registration, based on the value they select in a list field on the user registration form. No custom code or Rules configuration required — simply map field values to roles through a clean admin interface and the module handles the rest.

Registration Auto-assign Role Easily (RARE) also provides optional per-role icon display. Upload an image for any role, optionally apply a Drupal image style, and display role icons on user profiles via a pseudo-field in Manage Display — no custom theming required.

Use Cases

  • A membership site that offers "Student", "Professional", and "Organisation" account types — the user picks their type at registration and is automatically placed in the correct role.
  • A community platform that displays a badge icon next to each user's name to indicate their membership tier or specialisation.
  • Any site where role assignment currently requires manual intervention by an administrator after each new registration.

Features

  • Multiple mapping rules. Define as many field-to-role rules as your site needs. Each rule independently maps one list field's allowed values to roles.
  • Any list field type. Works with list_string, list_integer, and list_float field types on the user entity.
  • Role icons. Upload a PNG, JPG, GIF, or SVG icon per role (max 2 MB). Optionally apply any configured Drupal image style and show a visible label beneath the icon.
  • Manage Display integration. Role icons are exposed as a pseudo-field ("Role Icons (RARE)") in the user entity Manage Display screen — enable, reorder, and configure per view mode without any custom code.
  • Proper file management. Uploaded icon files are tracked via Drupal's file usage API. Replacing or removing an icon correctly decrements the usage count so Drupal's file cron can reclaim orphaned files.
  • Cache-aware rendering. Role icon render arrays are tagged with config:rare.settings, ensuring cached user profile pages are invalidated whenever icon configuration changes.
  • Clean uninstall. Uninstalling the module removes all configuration and decrements file usage, leaving no orphaned config or permanently-flagged files.
  • No contributed module dependencies. Requires only Drupal core modules: user, field, image and file. The image module is optional and enables image style support for role icons.

Requirements

  • Drupal 11 or later
  • At least one list_string, list_integer, or list_float field added to the user entity (Configuration > People > Account settings > Manage fields)
  • At least one custom role beyond Anonymous and Authenticated
  • The core image module (optional — required only for image style support on role icons)

Installation

Install as you would any Drupal module. See Installing Drupal Modules for instructions.

After installation, navigate to Configuration > People > RARE Settings to configure role assignment rules and role icons.

Configuration

1. Add a list field to the user entity at Configuration > People > Account settings > Manage fields. Add the allowed values that users will choose from at registration (for example: "student", "professional", "organisation").
2. Go to Configuration > People > RARE Settings.
3. Under Role Assignment Rules, select the list field and map each of its allowed values to a Drupal role.
4. Optionally, under Role Icons, upload an icon image for each role, select an image style, and configure the label.
5. To display role icons on user profiles, go to Configuration > People > Account settings > Manage display and enable the Role Icons (RARE) field for the desired view mode.

Similar Projects

Role Assign
Allows administrators to delegate the ability to assign specific roles to other users during user editing. RARE is different — it targets automatic assignment at the moment of registration based on a field value, with no administrator intervention required.

Registration Role
Assigns a single configured role to all new registrants. RARE is different in that assignment is conditional — different roles are assigned based on what the user selects in a form field, and multiple independent mapping rules can run simultaneously.

Rules
A general-purpose event/condition/action automation framework that can be configured to assign roles on registration. RARE is different in that it requires no contributed module dependencies and no Rules knowledge — the mapping is configured through a single focused admin form.

Supporting this Module

Report Bugs: Help improve stability by reporting issues in the issue queue
Submit Patches: Contribute code improvements and new features
Write Documentation: Share your use cases and configuration tips
Spread the Word: Star the project, write blog posts, or mention it in forums

Community Documentation

A great place to add links to YouTube walkthroughs, external documentation, or a demo site (use DrupalPod!).

Activity

Total releases
1
First release
Mar 2026
Latest release
2 days ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.0.0 Stable Mar 2, 2026