Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active May 25, 2018 16:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/44f47386d1221b7916d3ae906f6149c3 to your computer and use it in GitHub Desktop.
Save Pebblo/44f47386d1221b7916d3ae906f6149c3 to your computer and use it in GitHub Desktop.
Example of how to hide the 'Personal Information' email question for all additional registrants and then copy the email address set by the Primary Registrant to all other email fields.
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_copy_primary_email_to_all() {
wp_add_inline_style(
'single_page_checkout',
'.spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email-input-dv, .spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email {
display: none;
}'
);
wp_add_inline_script(
'single_page_checkout',
'jQuery("input.ee-reg-qstn-email").change(function() {
jQuery("input.ee-reg-qstn-email").val(jQuery(this).val());
});'
);
}
add_action( 'wp_enqueue_scripts', 'tw_ee_copy_primary_email_to_all', 11 );
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_copy_primary_email_to_all() {
$checkout = EE_Registry::instance()->SSN->checkout();
if ( $checkout instanceof EE_Checkout ) {
$transaction = $checkout->transaction;
if ( $transaction instanceof EE_Transaction ) {
foreach ( $transaction->registrations() as $registration ) {
if ( $registration instanceof EE_Registration ) {
$event = $registration->event();
if( $event->get_post_meta('hide_email_fields', true ) ) {
wp_add_inline_style(
'single_page_checkout',
'.spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email-input-dv, .spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email {
display: none;
}'
);
wp_add_inline_script(
'single_page_checkout',
'jQuery("input.ee-reg-qstn-email").change(function() {
jQuery("input.ee-reg-qstn-email").val(jQuery(this).val());
});'
);
break;
}
}
}
}
}
}
add_action( 'wp_enqueue_scripts', 'tw_ee_copy_primary_email_to_all', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment