Catching member record activation with a hook
Hi folks,
I'm really hoping someone with a bit more development knowledge than me can help me solve this problem...
I want to catch the status change of a member record from inactive to active, so I can have the system report with an email to the user that their account is now active.
I know there exists already the frontend "activateAccount" hook, but that is not good for my purpose. I want a *backend* hook that will catch both records being updated from the backend "edit member" screen, and also those AJAX state changes when you click the green publisher "eye" icon to toggle a member on and off. The "activateAccount" hook only handles front end activations when you click a link to verify your email address, and as such isn't much use in this case.
Does ANYONE know...where would be the best place to hook such a function into the system??
Many thanks in advance,
Dubs.
Re: Catching member record activation with a hook
PS> my two lame ideas so far are:
a) to try and catch record updates by hooking into the log action for "a member record was updated"
b) to try and catch those AJAX state changes by spotting the GET parameters somewhere low level on the backend like parseBackendTemplate
Surely these can't be the best ways to do that? It's just so MESSY!
Re: Catching member record activation with a hook
Can't you use a callback? https://contao.org/en/manual/3.0/data-c ... #callbacks
In your case either onsubmit_callback (entire record) or save_callback (field specific)
Re: Catching member record activation with a hook
I think your best bet is as suggested by Ruud to use save_callback for the field
Code:
$GLOBALS['TL_DCA']['tl_member']['fields']['disable']['save_callback'][] = array('YourClass', 'yourFunction');
Re: Catching member record activation with a hook
Thank you! That's so simple and helpful. I didn't know that these callbacks existed. It's just what I needed :-)