XF 2.2 How run addon code when user registration is complete and/or approved

lobanz

New member
First addon. Read the docs, watched the videos. Loving it so far.

Need to run some code in my addon when the user registration is complete. This code needs to remove (or blank out) a custom user field that was required at registration (and validated via a Validator in my addon) (or blank it out). And then modify a custom entity after the user registration is complete. The custom field and its Validator are working swimmingly.

So it looks like I can do this via the Class Extension mechanism by overriding XF\Pub\Controller\Register.finalizeRegistration(). I have this working in that I can get it to stop at a breakpoint in finalizeRegistration() my subclass.

My questions are:
  • Is this the right place to do it?
  • Am I going about it all wrong and there is a better way to do it?
  • Where would be a good place to put code when the account registration is approved?

'Preciate it!
 
That would probably work, but it might be better to extend the registration service (\XF\Service\User\Registration). You can probably extend \XF\Service\User\RegistrationComplete if you need to do something when the account becomes valid (or use the post-save hook on the user entity itself, depending on your needs).
 
That would probably work, but it might be better to extend the registration service (\XF\Service\User\Registration). You can probably extend \XF\Service\User\RegistrationComplete if you need to do something when the account becomes valid (or use the post-save hook on the user entity itself, depending on your needs).

Thanks! I ended up extending XF\Service\User\Registration.sendRegistrationContact(). Couldn't get it to breakpoint in RegistrationComplete. Don't know how to detect when the registration is approved. Don't need that at this point though.

Now I need to figure out how to add a custom user field from my addon. Seems to be the only thing that XF doesn't associate with an addon. Guess I'll have to add it in the Setup.php and also handle uninstall.

XF does seem to be a fantastic piece of work. Bravo to the XF devs!
 
Couldn't get it to breakpoint in RegistrationComplete. Don't know how to detect when the registration is approved.
FWIW the RegistrationComplete service should be fired when the account is approved (or otherwise becomes valid).
 
Back
Top Bottom