Results 1 to 5 of 5

Thread: Catching member record activation with a hook

  1. #1
    New user
    Join Date
    03-01-13.
    Posts
    10

    Default 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.

  2. #2
    New user
    Join Date
    03-01-13.
    Posts
    10

    Default 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!

  3. #3
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default 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)

  4. #4

    Default 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');
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  5. #5
    New user
    Join Date
    03-01-13.
    Posts
    10

    Default 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 :-)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •