Skip to content

Instantly share code, notes, and snippets.

@joshfeck joshfeck/reg_code_example.php Secret
Created Feb 5, 2019

Embed
What would you like to do?
Example that shows how to customize the Event Espresso REG_code
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__Create__regCode__new_reg_code',
'my_custom_new_reg_code_function',
10,
3
);
function my_custom_new_reg_code_function(
$reg_code,
$transaction,
$ticket
) {
// EE doesn't store sequential ID's
// so let's make an option to hold the last one.
$unique_incr_num = get_option( 'my_current_reg_id' );
// if the option is not set, then let's make it 1
if( !isset($unique_incr_num) ) {
$unique_incr_num = '1';
}
// otherwise lets increment it and then update the option.
else {
$unique_incr_num = (int)$unique_incr_num + 1;
update_option( 'my_current_reg_id', $unique_incr_num );
}
return 'FAPSA2019-' . $unique_incr_num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.