Support

Home Forums Event Espresso Premium Custom Registration ID (3)

Custom Registration ID (3)

Posted: February 4, 2019 at 1:17 pm

Viewing 6 reply threads


koopmanw

February 4, 2019 at 1:17 pm

Hi,
I realise that this has been addressed before (in 2015) but I don’t see any queries (and resolutions) relating to it in 2018.
I wish to create a registration ID that is formatted as follows:
FAPSA2019-[unique incremental number]
How should one go about it?
Your response would be greatly appreciated.

  • This topic was modified 5 years, 8 months ago by koopmanw.
  • This topic was modified 4 years, 8 months ago by Garth.


Josh

  • Support Staff

February 4, 2019 at 7:48 pm

Hi,

Was this the reply you saw from 2015?

https://eventespresso.com/topic/custom-registration-code-2/#post-156558

If so, the way one would go about this in 2019 is roughly the same, but the filter from 2015 has been deprecated. So instead one would use:
FHEE__Create__regCode__new_reg_code

Some example code follows:

https://gist.github.com/joshfeck/3b2b215eae663f26606f9d340ab68af4

You can add the above to a functions plugin, then activate the plugin to begin customizing the REG_code.


koopmanw

February 16, 2019 at 2:58 pm

Thanks so much for your response, Josh and apologies for only getting back now.
I was pushing to get another site launched.
I shall try the approach you mention and provide feedback.
Regards


koopmanw

February 16, 2019 at 3:17 pm

Josh, Thanks! It worked.
May I bug you once more, please. If I wanted to have the incrementing number to be three digits instead of one so, for example:
FAPSA2019-001
FAPSA2019-002 etc
How would I do that. I tried adding zeros but it doesn’t produce the desired effect.
Your help is greatly appreciated, thank you.


Tony

  • Support Staff

February 18, 2019 at 5:13 am

001 as an int will always be stored as 1 so you can’t just add them to the option, but what you can do is pad the value before returning it using str_pad()

So line 28 of Josh’s example could be:

return 'FAPSA2019-' . str_pad($unique_incr_num, 3, '0', STR_PAD_LEFT);

If $unique_incr_num = 1 then the above would output FAPSA2019-001

If $unique_incr_num = 12 then the above would output FAPSA2019-012

If $unique_incr_num = 123 then the above would output FAPSA2019-123

If $unique_incr_num = 1234 then the above would output FAPSA2019-1234


Tony

  • Support Staff

February 18, 2019 at 5:20 am

Also, rather than hardcoding the year into the string, you could use date('Y') to pull the current year.

return 'FAPSA' . date("Y") .'-' . str_pad($unique_incr_num, 3, '0', STR_PAD_LEFT);


koopmanw

February 18, 2019 at 6:20 am

Thanks, so much, Tony. I shall try this and revert.

Regards

Viewing 6 reply threads

The support post ‘Custom Registration ID (3)’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso