We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10378
    • 375 Posts
    Hello,

    I'd like to remove related data from a custom table if a MODx user object is removed. Found two event types which should do the job - but what's the difference between OnUserRemove and OnUserFormDelete?
    Which one should I use?

    Greetings,
    Martin

    This question has been answered by BobRay. See the first response.

      Freelancer @bitego http://www.bitego.com
      ---
      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
      More infos here: http://www.bitego.com/extras/goodnews/
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I believe that OnUserRemove has to do with removing from groups.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 10378
        • 375 Posts
        Quote from: sottwell at Jun 22, 2013, 03:19 PM
        I believe that OnUserRemove has to do with removing from groups.

        I don't think so Susan, the MODx docu says:

        OnUserDelete -> Fires after a User is deleted.
        OnUserRemove -> Fires after a User is removed.

        So whats the difference between both?
          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/
        • discuss.answer
          • 3749
          • 24,544 Posts
          I think the difference is that OnUserRemove is part of the modUserClass and should fire whenever a user is deleted from the DB, regardless of the method. So it would fire even if the user was removed this way:

          $user->remove();


          OnUserFormDelete is fired by the user/delete processor. It will only be called if the processor is used to delete the user. I can't find any cases where that processor is called, but that doesn't necessarily mean there aren't any. If it is called, my guess is that it would only fire if the user is deleted in the Manager in Security -> Manage Users.

          OnUserDelete doesn't exist in 2.2.8.

          I've found with this kind of thing, the best way to investigate is to create a plugin tied to one event that logs something, either to the error log or by writing to a chunk, then try deleting a user in various ways and see if the plugin code is executed.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting