Support

Home Forums Event Espresso Premium Use only the email value from attendee #1's information for all attendees

Use only the email value from attendee #1's information for all attendees

Posted: July 10, 2018 at 11:37 am


WF

July 10, 2018 at 11:37 am

Hi,

In my registration form I want the feature “USE ATTENDEE #1’S INFORMATION FOR ALL ATTENDEES” to populate only the email field of the other attendees.

I understand this feature will populate every question that matches the fields in #1, so I thought of building a custom group of questions for all additional registrants where only the email field was replicated from the original group.

But apparently it’s not possible to add the default email question to a custom group.

Which takes me back to my question:
Is there a way of replicating only the email field for all other attendees?

Many thanks


Josh

  • Support Staff

July 10, 2018 at 11:48 am

Yes there is, but it does not involve the Copy button on the registration form. Instead, you add some custom code to your site:

https://gist.github.com/joshfeck/5cad70f0b927e0950b1877f9a4f18fa5

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


WF

July 11, 2018 at 3:33 am

Hi Josh,

Thanks for the fast response, but there’s something strange happening now.

I added the code to functions.php in my child theme and it just hid the email field for the other attendees. Which means the field is still in the form, it’s empty, it’s mandatory but it’s hidden.

And it doesn’t let me proceed to payment options because the email field is not filled in.

Is something missing in the code or am I not understanding what’s happening?

Many thanks


WF

July 11, 2018 at 8:43 am

I see, the value only gets copied when I manually edit the original email field. But that’s problematic because if a logged in user makes the purchase, the email field for the first attendee is automatically filled in with their account email and it doesn’t get copied to the remaining attendees.

Any way of going around this?

Thanks


WF

July 11, 2018 at 8:52 am

Another issue is that I need this to be optional.


Josh

  • Support Staff

July 11, 2018 at 9:19 am

You can add this code instead:

function ee_copy_primary_email_to_all() {
    wp_add_inline_script( 
        'single_page_checkout',
        'jQuery(document).ready(function($){
            $("input.ee-reg-qstn-email:not(:first)").val($("input.ee-reg-qstn-email:first").val());
        });
        jQuery("input.ee-reg-qstn-email").change(function() {
            jQuery("input.ee-reg-qstn-email").val(jQuery(this).val());
        });'
    );
}
add_action(
    'wp_enqueue_scripts', 
    'ee_copy_primary_email_to_all', 
    11 
);


WF

July 11, 2018 at 10:45 am

The examples were almost there. I bound the action from your example to a click and added a little button next to the original email field, to let the users chose.
Couldn’t do it without your examples, thank you very much!

The support post ‘Use only the email value from attendee #1's information for all attendees’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso