Paid Memberships Pro’s User Fields do not include built-in URL validation. As a site owner, you are using the “text field type” to collect URLs from members at checkout on your site.

This guide shows how to add a validation check for a URL to a custom text field, ensuring URLs include https:// or http://. If a user enters a URL without this format, they receive an error message prompting correction before they can complete their checkout. This keeps data clean and improves the user experience for your customers on your website.

Featured image code recipe on adding user field for 'https'

/

Understanding HTTP vs. HTTPS

This code recipe checks that any URL entered into a custom user text field includes either http:// or https://. These prefixes are known as URL schemes and are necessary for links to function properly on the web.

The difference between the two lies in security:

  • http:// stands for Hypertext Transfer Protocol and transmits data in plain text.
  • https:// stands for Hypertext Transfer Protocol Secure and encrypts data during transmission, protecting it from interception or tampering.

By validating that URLs include one of these schemes, your site ensures that links are both functional and reliable when displayed. It also helps standardize the way links are handled across member profiles and other areas, reducing the risk of broken links or formatting issues. This also creates a smoother experience for your members and visitors.

About the Code Recipe

This code adds validation at checkout for the user_url text field to collect a URL on your website.

Screenshot showing new user field named 'user_url'

Before implementing this code recipe:

  • You must have added your custom user text field type within Paid Memberships Pro.
  • Replace user_url on line 18 with the “name” of the custom user text field you want to add a URL validation check for.
Screenshot showing URL validation check

The Code Recipe

Adding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.

How to Customize This Code Recipe

If you need to add a URL validation to more than one text field, you can modify this code recipe to add validation for more than one text field. Here’s how you can extend its functionality:

  • Duplicate line 18 for as many URL fields you want to add, for example, 'youtube_video'  => 'Youtube Link',.
Cover image from ebook 29 Nuggets of Wisdom Volume 1 - Sample Collection

Download the book: Get 29 insights and ‘aha moments’ for new or veteran membership site business owners. Use these nuggets of wisdom to inspire or challenge you.



Was this article helpful?
YesNo