Support

Home Forums Event Espresso Premium Get field data upon registration of attendee

Get field data upon registration of attendee

Posted: July 8, 2019 at 11:00 pm

Viewing 1 reply thread


ppo

July 8, 2019 at 11:00 pm

Alright hope someone can give me a quick pointer. I’ve got a registration form like so
https://www.go2ppo.com/registration-checkout/?uts=1562645171&source=#checkout

You can see at the bottom there’s a checkbox to sign up for communication. I’d like to capture if this was ticket on submission. Found some code so I have this.

function espresso_track_successful_sale_manual( $Transaction, $status_updates ){
if ($Transaction instanceof EE_Transaction) {
$Primary_Registration = $Transaction->primary_registration();
if ($Primary_Registration instanceof EE_Registration) {
$Attendee = $Primary_Registration->attendee();
if ($Attendee instanceof EE_Attendee) {
$email = $Attendee->email();
$customer_name = $Attendee->fname();
$customer_surname = $Attendee->lname();
$wantmore = '';
$data = [
'email' => $email,
'status' => 'subscribed',
'firstname' => $customer_name,
'lastname' => $customer_surname
];
if($wantmore){
syncMailchimp($data);
}

}
}
}
}
add_action('AHEE__EE_Transaction_Processor__manually_update_registration_statuses','espresso_track_successful_sale_manual', 20, 2);

Now the question is how do I capture the value of that checkbox into wantmore? Is there a $post or get to that specific input? Appreciate pointers.


Tony

  • Support Staff

July 9, 2019 at 7:50 am

Hi there,

Your questions are linked to the EE_Registration object and $post wouldn’t be the registration, so no, there’s no $post to get that specific input.

You can use the EEM_Answer model to pull an answer for a specific question ID linked to a registration using something like:

$question_id = 111;
$answer_obj = EEM_Answer::instance()->get_registration_question_answer_object( $Primary_Registration, $question_id );
if ( $answer_obj instanceof EE_Answer ){
    //If we have an answer object, echo the 'pretty' value for it.
    echo $answer_obj->pretty_value();
}

An example (which the above is taken from) of that in use can be found here:

https://gist.github.com/Pebblo/88f2a0a9213c716e4886a249e7709245#file-example-php-L30

In short you pulling the answer to a specific question ID linked to a registration (which is why you pass the registration object and the question ID)

I recommend having a read through our model system documentation here:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

Viewing 1 reply thread

The support post ‘Get field data upon registration of attendee’ 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