I’m mostly looking at Custom Registration Questions being autopopulated. At the simplest – can you recommend a way to hook into EE4 to manually:
generate a Question Group
generate a specific Question
set an answer to that specific question
Or, if there’s no problem getting IDs for questions that are created within the EE4 Registration Form editor, can you recommend a way to hook in to manually:
Our WP User Integration offers pre-population for the personal question group. It does not currently pre-populate custom questions but there is a feature request for that.
I’ll add additional feedback to the feature request ticket.
It looks a lot to me like this is the function that’s calling the user data to the form:
/**
* Added to filter that processes the return to the registration form of whether and answer to the question exists for that
* @param type $value
* @param EE_Registration $registration
* @param int|string $question_id in 4.8.10 and 4.8.12 it is numeric (eg 23)
* but in 4.8.11 it is a system ID like "email"
* @param string $system_id passed in 4.8.12+ of EE core
* @return type
*/
public static function filter_answer_for_wpuser($value, EE_Registration $registration, $question_id, $system_id = null ) {
//only fill for primary registrant
if ( ! $registration->is_primary_registrant() ) {
return $value;
}
if ( empty($value) ) {
$current_user = wp_get_current_user();
/*there was a temporary bug in EE core relating to $question_id being passed
* in 4.8.10 it was a question's ID (eg 23)
* but in 4.8.11 it was changed to a SYSTEM ID (eg 'email')
* (and the new constants, like EEM_Attendee::system_question_fname, were introduced)
* but soon thereafter in order to fix that bug it was changed
* BACK to a proper question ID (eg 23) and a new parameter was passed,
* $system_id
*/
if( is_numeric( $question_id ) && ! defined( 'EEM_Attendee::system_question_fname' ) ) {
//4.8.10-style. Use the old constants
$firstname = EEM_Attendee::fname_question_id;
$lastname = EEM_Attendee::lname_question_id;
$email = EEM_Attendee::email_question_id;
$id_to_use = $question_id;
} elseif( ! is_numeric( $question_id ) && defined( 'EEM_Attendee::system_question_fname' ) ) {
//4.8.11-style. Use the new constants
$firstname = EEM_Attendee::system_question_fname;
$lastname = EEM_Attendee::system_question_lname;
$email = EEM_Attendee::system_question_email;
$id_to_use = $question_id;
} elseif( is_numeric( $question_id ) && defined( 'EEM_Attendee::system_question_fname' ) ) {
//4.8.12-style. Use the new constants and the $system_id
$firstname = EEM_Attendee::system_question_fname;
$lastname = EEM_Attendee::system_question_lname;
$email = EEM_Attendee::system_question_email;
$id_to_use = $system_id;
} else {
// ! is_numeric( $question_id ) && defined( 'EEM_Attendee::system_question_fname' )
//weird shouldn't ever happen. Just use the old default
$firstname = EEM_Attendee::fname_question_id;
$lastname = EEM_Attendee::lname_question_id;
$email = EEM_Attendee::email_question_id;
$id_to_use = $question_id;
}
if ( $current_user instanceof WP_User ) {
switch ( $id_to_use ) {
case $firstname :
$value = $current_user->get( 'first_name' );
break;
case $lastname :
$value = $current_user->get( 'last_name' );
break;
case $email :
$value = $current_user->get( 'user_email' );
break;
default:
}
}
}
return $value;
}
Is that accurate?
I’m wondering if there’s documentation on a few elements of this code.
First, and most importantly, it looks like we’re calling the users name with the following –
$firstname = EEM_Attendee::system_question_fname;
Is there a parameter available for other other slugs? Like…
Does that help much? I know it’s not exactly answering your questions, but I took a guess that this might be getting at the heart of what you’re wanting.
Viewing 4 reply threads
The support post ‘Linking Questions to User Meta in EE4 – Autofilling Registration’ 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.