GRAV CMS DEVELOPER

WhatsApp/Signal: +91-953-66666-77
Email ID: hello@gravdeveloper.com
Using Email as a username in registration Form in Grav Cms

Using Email as a username in registration Form in Grav Cms

  • Date: May 21, 2025
  • Tags: Grav Cms

To use an email address as the username in a Grav CMS registration form, you'll need to customize the form configuration to set the username field dynamically based on the user's email input. Here's how you can achieve this:

Steps to Use Email as Username in Grav Registration Form

Hide the Username Field: In your registration form configuration, set the username field to be hidden. Stack Overflow

yaml Copy Edit fields:

  • name: username type: hidden Set Username from Email: Use the fill process action to assign the email value to the username field.

yaml Copy Edit process:

  • fill: username: "{email}" Adjust Username Validation Regex: Grav's default username validation may not accept email formats. To allow email addresses as usernames, update the username_regex in your configuration.

yaml Copy Edit username_regex: '^[^@\s]+@[^@\s]+.[^@\s]+$' This regular expression permits standard email formats.

Ensure Email Field is Required: Make sure the email field is present and required in your form.

yaml Copy Edit fields:

Feel free to reach out if you'd like to make changes to your Grav website or simply chat about your Grav project. I'm available for a free consultation!