Created
June 28, 2021 16:02
-
-
Save Pebblo/1f0a3fbee4531a30bba14d2b04a05a72 to your computer and use it in GitHub Desktop.
Example on how you can prevent registrations if the email address has already been used on the event.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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