One of the requirements for a project was for the system to generate a unique ID for each of the members coming in. The logic of the unique ID is slightly complex. The unique ID will take the first alphabet of the surname and increment the number after the alphabet. Example John Tan, membership number will be T001 (Tan is his surname). Another example Ryan Tay, membership number will be T002 (Tay is his surname). If name if Tristan Ram, membership number will be R001 (Ram is his surname).

Just wondering whether is this possible? And how can I create such custom logic in CiviCrm?

1 Answer 1


I think you'll want to add a small extension that does this. So, you could add a custom field for this unique ID to memberships. Then you can set a hook_civicrm_postCommit for when a new membership is created and then use the API to check for the highest unique ID for that letter and set the new unique ID accordingly.

Alternatively, you could possibly add this as a custom CiviRules action.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.