<?php /** * This recipe adds the HTML5 attribute "required" to all required * fields on the checkout page that has the class "pmpro_required" * to check that a required field is not empty before submitting. * * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required * * 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. * https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ */ function my_pmpro_add_required_attribute_to_input() { if ( pmpro_is_checkout() ) { ?> <script> jQuery(document).ready(function ($) { jQuery('.pmpro_required').attr('required', 'required'); }); </script> <?php } } add_action( 'wp_footer', 'my_pmpro_add_required_attribute_to_input' );