A comprehensive Drupal 10 custom module for managing event registrations with admin configuration, user registration, validation, email notifications, and reporting features.
- Admin Event Configuration: Create and manage events with registration periods
- Public Registration Form: User-friendly form with AJAX-dependent dropdowns
- Validation: Email format, text field sanitization, and duplicate registration prevention
- Email Notifications: Automated emails to users and administrators
- Admin Dashboard: View and filter registrations with participant counts
- CSV Export: Export registration data for analysis
- Permissions: Role-based access control for all features
- Drupal 10.x
- PHP 8.1 or higher
- MySQL 5.7+ or MariaDB 10.3+
- Composer
-
Copy the module to your Drupal installation:
cp -r event_registration /path/to/drupal/web/modules/custom/
-
Enable the module using Drush:
drush en event_registration -y
Or enable via the Drupal admin interface:
- Navigate to Extend (
/admin/modules) - Find "Event Registration" under Custom modules
- Check the box and click Install
- Navigate to Extend (
-
Clear cache:
drush cr
-
Configure permissions:
- Navigate to People > Permissions (
/admin/people/permissions) - Assign appropriate permissions to roles:
administer event registration- For administratorsaccess event registrations- For viewing registration listsregister for events- For users who can register
- Navigate to People > Permissions (
-
Configure email settings:
- Navigate to Configuration > Event Registration Settings (
/admin/config/event-registration/settings) - Enter admin email address
- Enable/disable email notifications
- Navigate to Configuration > Event Registration Settings (
Stores admin-created events with registration periods.
| Field | Type | Description |
|---|---|---|
| id | INT (PK) | Unique event ID |
| reg_start_date | VARCHAR(20) | Registration start date (YYYY-MM-DD) |
| reg_end_date | VARCHAR(20) | Registration end date (YYYY-MM-DD) |
| event_date | VARCHAR(20) | Actual event date (YYYY-MM-DD) |
| event_name | VARCHAR(255) | Name of the event |
| category | VARCHAR(255) | Event category (e.g., Online Workshop) |
Indexes:
idx_categoryoncategoryidx_event_dateonevent_date
Stores user registrations for events.
| Field | Type | Description |
|---|---|---|
| id | INT (PK) | Unique registration ID |
| full_name | VARCHAR(255) | Full name of the registrant |
| VARCHAR(255) | Email address of the registrant | |
| college_name | VARCHAR(255) | College name of the registrant |
| department | VARCHAR(255) | Department of the registrant |
| category | VARCHAR(255) | Event category |
| event_date | VARCHAR(20) | Event date (YYYY-MM-DD) |
| event_id | INT (FK) | Foreign key to event_configuration table |
| created | INT | Timestamp when registration was created |
Indexes:
idx_emailonemailidx_event_dateonevent_dateidx_event_idonevent_id
Foreign Key:
event_idreferencesevent_configuration(id)with CASCADE on delete
| URL | Permission Required | Description |
|---|---|---|
/admin/config/event-registration/events |
administer event registration | Create and configure events |
/admin/config/event-registration/settings |
administer event registration | Configure module settings |
/admin/event-registration/list |
access event registrations | View and filter registrations |
/admin/event-registration/export |
access event registrations | Export registrations to CSV |
| URL | Permission Required | Description |
|---|---|---|
/event/register |
register for events | Public event registration form |
The module implements comprehensive validation to ensure data integrity:
- Uses PHP's
filter_var()withFILTER_VALIDATE_EMAIL - Ensures proper email format (e.g., user@example.com)
- Applied to both user registration and admin settings
- Pattern: Only alphanumeric characters and spaces allowed
- Regex:
/^[a-zA-Z0-9\s]+$/ - Applied to:
- Full Name
- College Name
- Department
- Event Name
- Registration end date must be after start date
- Event date must be on or after registration end date
- Prevents illogical date configurations
- Check: Email + Event Date combination
- Query:
SELECT id FROM event_registration WHERE email = ? AND event_date = ?
- Error Message: "You are already registered for this event."
- Prevents users from registering multiple times for the same event
- Admin email address stored in
event_registration.settingsconfig - Enable/disable toggle for notifications
- No hardcoded email addresses
Sent to: User's email address
Trigger: Successful registration
Contains:
- Full name
- Event name
- Event category
- Event date
- College name
- Department
Sent to: Admin email (from settings)
Trigger: Successful registration
Contains:
- All participant details
- All event details
- Uses Drupal Mail API via
MailManagerInterface - Dependency injection for testability
- Implements
hook_mail()for message formatting - Only sends if notifications are enabled in settings
The registration form uses nested AJAX callbacks for dynamic field updates:
- User selects a category
- AJAX callback
updateEventDates()triggers - Event date dropdown populates with dates for selected category
- Only shows events where current date is within registration period
- User selects an event date
- AJAX callback
updateEventNames()triggers - Event name dropdown populates with events matching category + date
- Only shows active events
Events are considered "active" when:
current_date >= reg_start_date AND current_date <= reg_end_date
- Filtering: By event date and event name (AJAX-dependent)
- Display: Sortable table with all registration details
- Count: Shows total number of participants
- Pagination: Supports large datasets
- Format: Standard CSV with headers
- Filename:
event_registrations_YYYY-MM-DD_HH-MM-SS.csv - Columns:
- Full Name
- College
- Department
- Category
- Event Date
- Event Name
- Filtering: Respects current filter selections
All classes use proper dependency injection:
Connectionfor database operationsMailManagerInterfacefor emailConfigFactoryInterfacefor configuration
- ✅ No use of
\Drupal::service()in classes - ✅ Proper use of Config API
- ✅ Database API for all queries
- ✅ Form API for all forms
- ✅ Permissions on all routes
- ✅ Error handling and logging
- ✅ AJAX for better UX
event_registration/
├── event_registration.info.yml # Module metadata
├── event_registration.install # Database schema and hooks
├── event_registration.module # Hook implementations
├── event_registration.permissions.yml # Permission definitions
├── event_registration.routing.yml # Route definitions
├── event_registration.services.yml # Service definitions
├── event_registration_schema.sql # SQL export for submission
├── README.md # This file
└── src/
├── Controller/
│ ├── RegistrationExportController.php # CSV export
│ └── RegistrationListController.php # Admin listing
├── Form/
│ ├── EventConfigForm.php # Admin event config
│ ├── EventRegistrationForm.php # Public registration
│ ├── RegistrationFilterForm.php # Admin filter form
│ └── SettingsForm.php # Module settings
└── Service/
└── MailService.php # Email service
-
Create an Event:
- Go to
/admin/config/event-registration/events - Fill in event details (name, category, dates)
- Click "Create Event"
- Go to
-
Configure Email Settings:
- Go to
/admin/config/event-registration/settings - Enter your admin email
- Enable notifications if desired
- Go to
-
View Registrations:
- Go to
/admin/event-registration/list - Use filters to narrow down results
- View participant count
- Go to
-
Export Data:
- Apply desired filters
- Click "Export to CSV"
- Download the generated file
- Register for an Event:
- Go to
/event/register - Fill in personal details
- Select event category (dropdown populates from active events)
- Select event date (based on category)
- Select event name (based on category + date)
- Click "Register"
- Receive confirmation email
- Go to
- Check that notifications are enabled in settings
- Verify admin email is configured
- Check Drupal's mail configuration
- Review logs at
/admin/reports/dblog - Note for Localhost/XAMPP Users: If you are running this locally without a configured mail server (e.g., Sendmail/Postfix), you will see an "Unable to send email" error. This is expected behavior for the environment; the module logic is correct and will function properly on a live server.
- Clear Drupal cache:
drush cr - Check browser console for JavaScript errors
- Ensure jQuery is loaded
- Verify events are created in admin
- Check that current date is within registration period
- Ensure events have valid dates
Edit EventConfigForm.php line 68 to add options to the category dropdown.
Modify MailService.php methods:
buildUserEmailBody()for user emailsbuildAdminEmailBody()for admin emails
Add custom validation in form classes:
EventConfigForm::validateForm()EventRegistrationForm::validateForm()
This module is provided as-is for educational purposes.
For issues or questions, please contact the module maintainer or refer to Drupal.org documentation.
Version: 1.0.0
Drupal: 10.x
Last Updated: February 2026