Advertisement
Apina

EE4 custom reg code example

Nov 13th, 2014
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. //This code is not supported by Event Espresso
  2. //This code is merely an example of how to use the filter FHEE__EE_Registration___generate_new_reg_code__new_reg_code
  3.  
  4. function change_the_reg_id($new_reg_code, $this) {
  5.  
  6. //EE doesn't store sequential ID's so let's make an option to hold the last one.
  7. $the_last_reg_id = get_option( 'my_current_reg_id' );
  8.  
  9. //if the option is not set, then let's make it 1
  10. if( !isset($the_last_reg_id) ) {
  11. $the_last_reg_id = '1';
  12. }
  13. //otherwise lets increment it and then update the option.
  14. else {
  15. $the_last_reg_id = (int)$the_last_reg_id + 1;
  16. update_option( 'my_current_reg_id', $the_last_reg_id );
  17. }
  18.  
  19. //modify the reg code with the new one and return it.
  20. $new_reg_code = $the_last_reg_id;
  21. return $new_reg_code;
  22. }
  23. add_filter('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', 'change_the_reg_id', 10,2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement