XF 2.2 Listen for when account confirmation succeeds

kmecpp

Member
I'm trying to make an addon that performs some logic when XenForo confirms the users email address. What's the best way to do this?
 

Lukas W.

Well-known member
Either user entity post save listening for a state change in the user state field or an extension for the service class that handles email confirmation.
 

kmecpp

Member
Either user entity post save listening for a state change in the user state field or an extension for the service class that handles email confirmation.
I made an entity save listener but how is it possible to detect that the user state went from email_confirm to valid when you only have the final entity?

Originally I implemented a preSave handler to add potential users to an array in addition to a postSave handler to access it, but it seems like the state for even a static class variable is not shared.
 

Lukas W.

Well-known member
The default pre/post save methods of the user object have sample code for that in place I believe. If not, you can look into thread & post pre/post save
 

kmecpp

Member
Thanks! In postSave it's just

Code:
if($entity->getExistingValue('user_state') == 'email_confirm' && $entity->user_state == 'valid')
 
Last edited:
Top