Select existing Team Name and assign Team Number

  • Cory S
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
22 hours 55 minutes ago - 14 hours 25 minutes ago #175902 by Cory S
This plugin, TeamNumberAssignment, and new field type allows event registrants to either join an existing team or create a new team, and auto-assign a team #. Team members who register with the same team name are automatically assigned the same team number. This is event-specific. It should work for fields on both Billing and Registration Group records.

It's comprised of a plugin that you install normally, which takes care of the Team# assignment. It also adds a new SQLCustom field type, which uses SQL to lookup existing values in the database for Team Name. This field is an improvement over the existing SQL custom field because it allows you to add a new value, instead of only selecting from existing values.

Normal disclaimer, use at your own risk, not responsible for any damage caused by using this plugin.

=================
OverviewThis plugin and new field type allows event registrants to either join an existing team or create a new team, and auto-assign a team #. Team members who register with the same team name are automatically assigned the same team number. This is event-specific.

Tested Against: Events Booking 5.3.1, Joomla 5.4.0

 Components
1. Custom Field Type: SQLCustom
File: 
Code:
sqlcustom.php
Location:
Code:
/administrator/components/com_eventsbooking/libraries/rad/form/field/sqlcustom.php
Type: Events Booking field type extension (NOT a plugin)PurposeProvides a dual-input field that:
- Shows a dropdown of existing values for a field (e.g. Team Names) from the SQL query so registrants can choose an existing value
- Provides a text input for entering a new value
- Automatically hides the text input when an existing value is selectedFeatures
  • Executes SQL queries to populate dropdown options
  • Supports placeholders like 
    Code:
    [EVENT_ID]
     in SQL queries
  • Syncs dropdown and text input with JavaScript
  • Inherits validation and styling from parent RADFormFieldSQL class
Installation
AUTOMATIC INSTALLATION - The SQLCustom field type is automatically installed when you install the Team Number Assignment plugin.The plugin's installation script will automatically copy 
Code:
sqlcustom.php
 to: 
Code:
/administrator/components/com_eventsbooking/libraries/rad/form/field/

If the automatic installation fails, you can manually upload 
Code:
sqlcustom.php
 to the location above and clear Joomla cache.

⚠️ IMPORTANT - UpdatesThis file will be DELETED when Events Booking is updated!

When creating/editing a custom field:- Field Type: Choose SQLCustom
Default Values: Enter a SQL query to get the existing values from the database for this field. (sample sql provided below)

2. Plugin: Team Number Assignment
Plugin Name: Events Booking - Team Number Assignment
Folder: 
Code:
teamnumberassignment
Location:
Code:
/plugins/eventbooking/teamnumberassignment/
Type: Joomla Plugin (eventbooking group)
PurposeAutomatically assigns team numbers to registrants based on their team name:
- Same team name → Same team number
- New team name → Next available team number (no upper limit)
- Works for both individual and group registrations
- Configurable field IDs for flexibility Files
Code:
/plugins/eventbooking/teamnumberassignment/ ├── teamnumberassignment.php (Main plugin code) ├── teamnumberassignment.xml (Plugin manifest) ├── script.php (Installation script) └── sqlcustom.php (SQLCustom field type - auto-installed)
Installation
  1. Go to: Extensions > Manage > Install
  2. Upload the ZIP file
  3. The installation script will automatically copy sqlcustom.php to Events Booking folder
  4. Go to: Extensions > Plugins
  5. Find "Events Booking - Team Number Assignment"
  6. Click to open the plugin
  7. REQUIRED: Configure the plugin settings:
    • Team Name Field ID: Enter the field ID for your Team Name field (e.g., 22)
    • Team Number Field ID: Enter the field ID for your Team Number field (e.g., 36)
  8. Enable the plugin
  9. Save & Close
⚠️ CRITICAL: The plugin will NOT work until you configure both field IDs. If the field IDs are not configured, users will see an error message during registration.How It Works
  1. Hooks into 
    Code:
    onAfterStoreRegistrant
     event
  2. Checks that field IDs are configured (shows error if not)
  3. Retrieves the Team Name from the configured Team Name field
  4. Checks if team name already exists for this event
  5. If exists: Assigns the same team number
  6. If new: Finds the highest existing team number and assigns next number (max + 1)
  7. Saves team number to the configured Team Number field
  8. For group registrations: Processes each group member individually
    • Assigns team numbers based on each member's team name
    • Handles cases where group members have different team names
    • Also processes billing record if it has a team name
This plugin is SAFE during Joomla updates - It will NOT be deleted or overwritten.Events Booking updates also will not affect this plugin.
After Events Booking Updates: Simply reinstall or update this plugin to restore the SQLCustom field type.

Setting up Custom Fields
Field 1: Team Name
  • Field ID: (set by the system, e.g. 22)
  • Field Type: SQLCustom
  • Title: Team Name
  • Name: team_name
  • Required: Yes (recommended)
  • Show on Registration Form: Yes
  • Default Values (SQL):
    Code:
    sql SELECT DISTINCT fv.field_value AS value, fv.field_value AS text FROM jml_eb_registrants r INNER JOIN jml_eb_field_values fv ON r.id = fv.registrant_id WHERE r.event_id = [EVENT_ID] AND fv.field_id = 22 AND fv.field_value IS NOT NULL AND fv.field_value != '' ORDER BY fv.field_value
    Note: Change 
    Code:
    fv.field_id = 22
     in the SQL to match your actual Team Name field ID.
Field 2: Team Number
  • Field ID: (set by the system, e.g. 36)
  • Field Type: Text or Integer
  • Title: Team Number
  • Name: team_number
  • Required: No
  • Show on Registration Form: No (Hidden)
  • Default Values: (leave empty)
Important: Team Number should be hidden from users - they should not see or interact with it.How It Works - User ExperienceIndividual Registration
  1. User clicks "Register" for an event
  2. Sees "Team Name" field with:
    • Dropdown showing existing teams: "-- Select from existing or enter new below --"
    • Text input field below it
  3. User can either:
    • Option A: Select existing team from dropdown (text input hides)
    • Option B: Type new team name in text input
  4. User completes registration
  5. Team Number is automatically assigned (user never sees it)
Group Registration (e.g., 2+ people)
  1. User registers group with Team Name "Krank"
  2. Plugin assigns Team# 3 to:
    • Member 1 (if they have Team Name filled in)
    • Member 2 (if they have Team Name filled in)
    • Billing record (if it has Team Name filled in)
  3. All records with the same team name get the same Team#
Team Member Joining Later
  1. New user registers individually
  2. Selects "Krank" from dropdown
  3. Plugin sees this team already exists
  4. Assigns same Team# 3 to new member
Last edit: 14 hours 25 minutes ago by Cory S.

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
22 hours 14 minutes ago #175903 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Select existing Team Name and assign Team Number
Thanks Cory for sharing your work back to community

Regards,

Tuan

Please Log in or Create an account to join the conversation.