Skip to content

Instantly share code, notes, and snippets.

@Apina
Last active August 29, 2015 14:14
Show Gist options
  • Save Apina/d0ce690b8af1cad64135 to your computer and use it in GitHub Desktop.
Save Apina/d0ce690b8af1cad64135 to your computer and use it in GitHub Desktop.
EE4 modify registration ID
<?php
// Please do NOT include the opening php tag, except of course if you're starting with a blank file
function change_reg_code($new_reg_code, $registration) {
//create a new reg ID e.g. business-1598
$new_reg_code = "business-" . rand(1000, 10000);
//send the new reg code back to be used.
return $new_reg_code;
}
add_filter('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code','change_reg_code', 10, 2);
/*
*
* This example will update a count for the registration code and keep it incremental
* The event with need a Custom Field called count adding, with a value of 1
*
* There is a flaw with this system in that as the registration ID is produced early on
* if the registration is abandoned the count will still have been incremented.
*/
function change_reg_code($new_reg_code, $registration) {
$eventid = $registration->event_ID();
$count = get_post_meta( $eventid, 'count', true );
//create a new reg ID e.g. business-count-1598
$new_reg_code = "my_count-" . $count . '-' . rand(1000, 10000);
$newcount = (int)$count + 1;
update_post_meta($eventid, 'count', $newcount, $count);
//send the new reg code back to be used.
return $new_reg_code;
}
add_filter('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code','change_reg_code', 10, 2);
@Apina
Copy link
Author

Apina commented Mar 6, 2015

Code was broken, fixed it. Also updated the filter hook as the original no longer exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment