Dev.to•Jan 29, 2026, 3:50 AM
Gravity forms devs unleash PHP sorcery to let users skip 'https://' for 'www.', because nothing says progress like fixing form fields at 2am

Gravity forms devs unleash PHP sorcery to let users skip 'https://' for 'www.', because nothing says progress like fixing form fields at 2am

Gravity Forms, a popular WordPress plugin, validates website fields to ensure users enter properly formatted URLs, often causing issues for those who enter URLs starting with "www" without the protocol. To address this, developers can customize the validation rules using hooks and filters provided by Gravity Forms. A specific code snippet can be added to a WordPress child theme or via a plugin like Code Snippets, allowing URLs starting with "www" to be accepted by prepending the "https://" protocol internally. This solution uses the `gform_field_validation` filter to intercept the validation process and check if the input starts with "www". If valid, it sets the validation result to true and clears any error message. By implementing this solution, users can enter URLs like "www.example.com" without needing to type the full protocol, improving user experience and reducing unnecessary validation errors. This modification is particularly useful for contact forms and user-input forms.

Viral Score: 70%

More Roasted Feeds

No news articles yet. Click "Fetch Latest" to get started!