Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example on how you can prevent registrations if the email address has already been used on the event.
<?php // Please do not include the opening PHP tag if your already have one.
function tw_ee_attendee_information__process_reg_step($process_reg_step, $reg_step, $spco) {
//Stop processing for testing
//$process_reg_step = false;
// Pull the transaction from checkout.
$transaction = $spco->checkout->transaction;
if($transaction instanceof EE_Transaction) {
// We need to process the registrtion data, to do that we need the registrations
$registrations = $transaction->registrations();
// Now process the data from the reg_step
$valid_data = $reg_step->valid_data();
$personal_info_identifier = EEM_Question_Group::instance()->get_var(
array(
array(
'QSG_system' => EEM_Question_Group::system_personal
),
),
'QSG_identifier'
);
//Loop over each question group assigned to the primary registrant and pulls it's questions.
foreach($registrations as $reg) {
if( isset( $valid_data[ $reg->reg_url_link() ][$personal_info_identifier]) ) {
$email = $valid_data[ $reg->reg_url_link() ][$personal_info_identifier]['email'];
$count = EEM_Registration::instance()->count(
array(
array(
'EVT_ID' => $reg->event_ID(),
'Attendee.ATT_email' => $email
)
)
);
if( $count ) {
$error = 'SPCO has been stopped before registrations have been processed';
EE_Error::add_error(esc_html__($error, 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
return false;
}
}
}
}
return $process_reg_step;
}
add_filter('AHEE__Single_Page_Checkout__process_reg_step__attendee_information__process_reg_step','tw_ee_attendee_information__process_reg_step', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment