Skip to content

Instantly share code, notes, and snippets.

@lorenzocaum
Last active September 19, 2015 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzocaum/34e45008a9f7bf32ee34 to your computer and use it in GitHub Desktop.
Save lorenzocaum/34e45008a9f7bf32ee34 to your computer and use it in GitHub Desktop.
Disable the first name and last name fields in the personal question group in registration checkout for Event Espresso 4

This sample coding can be added to your child theme’s functions.php file (do not include the opening php tag) or a site specific plugin:

http://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

123 should be changed to your page ID of your actual registration checkout page. This can be found by going to your WP dashboard and clicking on the registration checkout WordPress page. The ID appears at the end of the URL.

For example, if the ID for your registration checkout page was 1357, then you should use that value in the sample coding instead of 123.

Add the sample code below to your child theme's functions.php file or in a site specific plugin.

<?php
//* Do NOT include the opening php tag
 
//* Disable the first name and last name fields during registration checkout
function ee_disable_name_fields_registration_checkout() {
      if ( is_page( 123 ) ) {
        ?>
        <script>
        jQuery(document).ready( function($) {
          jQuery("input[id$=-fname]").prop( "readonly", true );
          jQuery("input[id$=-lname]").prop( "readonly", true );
        });
        </script>
        <?php
    }
}
add_action('wp_footer', 'ee_disable_name_fields_registration_checkout');
@Apina
Copy link

Apina commented Apr 6, 2015

Note, if you are having issues with validation, try readonly instead of disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment