Support

Home Forums Event Espresso Premium Populate Primary Registrant details from User system questions

Populate Primary Registrant details from User system questions

Posted: January 23, 2020 at 2:06 am


codingforsail

January 23, 2020 at 2:06 am

Hi,

I found this code snippet: https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/jf_filter_address_answer_for_wpuser.php

As far as my understanding of reading that code goes, it should populate the user’s system fields from the values that may exist in Event Espresso. Is my understanding correct?

If so, is there anything that would go the other way, and populate the questions in Event Espresso if they exist in the user’s system fields?

Reason I am asking is that we have a user registration form that asks those questions using WP-Members plugin. I would then like those answers to be pre-populated when the user goes on to complete their event booking.

I will give a link and login details in a private reply so you can see what I mean.

Kind regards,

Anita
http://wordpress-201401-1087397.cloudwaysapps.com/event-list/


codingforsail

January 23, 2020 at 2:07 am

This reply has been marked as private.


Tony

  • Support Staff

January 23, 2020 at 2:37 am

As far as my understanding of reading that code goes, it should populate the user’s system fields from the values that may exist in Event Espresso. Is my understanding correct?

No.

That code pulls values from the EE_Contact linked to the current WP user that is logged in and auto-fills the address questions on the registration form.

The easiest way to highlight which values they are is with a screenshot: https://monosnap.com/file/Vfnc49XC8GQzeqjhZQgizJX6GzBjbN

Event Espresso -> Registrations -> Contact list -> {click on the contact linked to the user}

The address questions there are the ones being pulled and autofilled on the registration form using that snippet.

All registrations made in EE are connected with a ‘EE_Contact’ object, that is created from the values in the registration form when a registration is made. EE will check its current EE_Contacts for any that match the first name, last name and email address exactly when a registration is made, if it finds one it links the registration to that contact rather than creating another.

The WP User integration add-on sets up a relationship with the logged-in WP user account and EE contact create/found during the registration they make.

So the code about is simply saying:

1. Pull the EE_Contact linked to the current user.
2. If we have an EE_Contact object (you may not always have one) pull the address questions from that contact and autofill them on the address group.

Note that other than the connection between the WP User account and then EE_Contact (which is important) the WP User account details don’t come into it.

You could modify that snippet to pull the values directly from the WP User account if preferred, if those are different from the values set on the contact linked at the time they will be updated on submission.


codingforsail

January 24, 2020 at 4:21 am

Thanks for the explanation. I have done that.

Can that be made to work for custom fields, eg mobile phone?

Or is there a similar filter that can be changed to deal with such questions?


codingforsail

January 24, 2020 at 4:45 am

I think I’ve found the filter I need:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/mn_wp_user_addon_save_custom_answers_too.php


Tony

  • Support Staff

January 24, 2020 at 6:33 am

Yeah, that filter runs for each question input on the registration form so you can use that to autofill using User data.

The support post ‘Populate Primary Registrant details from User system questions’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Tony 3 weeks, 3 days ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!