Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Plugin hook for discussion posts?

Hey guys and girls.

I'm trying to write a fairly simple plugin for a community site I'm developing, and I need to fire an event/hook when a user posts a new discussion. This will update a few fields in our own DB. I've tried having a look through the source, but I was unable to find the function that deals with the actual posting. Unless I'm currently blind, which may be the case haha. Any pointers in the right direction or the function name I need to hook up in my plugin?

Thank you in advance,
Tristan.

Comments

  • x00x00 MVP
    edited November 2012

    You need to hook the model, in MVC system is the model that is associated with database entry.

    The model concerned is the DiscussionModel, the events you could use are BeforeSaveDiscussion, and AfterSaveDiscussion (look in /application/vanilla/models/class.discussionmodel.php)

    e.g

    public function DiscussionModel_AfterSaveDiscussion_Handler($Sender,$Args){
         $FormPostValues = $Args['FormPostValues'];
         $ValidatedFields = $Args['Fields'];
         $DiscussionID = $Args['DiscussionID'];
    
    }
    

    grep is your friend.

  • Thank you x00, exactly what I needed!

Sign In or Register to comment.