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.

Is PostController_BeforeSaveComment_Handler working?

TiGRTiGR
edited November 2010 in Vanilla 2.0 - 2.8
I'm trying to write a plugin that interferes in posting and applies some formatting rules to post body. I've written something like this:

public function PostController_BeforeSaveComment_Handler(&$Sender) { } public function PostController_BeforeSaveDiscussion_Handler(&$Sender) { }

But this code just does not work. No matter what I put into these functions (even die()) it's clear, that these just never get called. I've tried using different controllers, but that didn't help also.
Tagged:

Comments

  • TimTim Vanilla Staff
    I'm pretty sure (if memory serves) that the events are called "BeforeCommentSave" and "BeforeDiscussionSave" ... not SaveComment or SaveDiscussion. Try that ;)

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Nah, didn't help.

    BTW:$ grep -E "Save(Discussion|Comment)" applications/ -R applications/vanilla/models/class.commentmodel.php: * Events: BeforeSaveComment, AfterSaveComment. applications/vanilla/models/class.commentmodel.php: $this->FireEvent('BeforeSaveComment'); applications/vanilla/models/class.commentmodel.php: $this->FireEvent('AfterSaveComment'); applications/vanilla/models/class.discussionmodel.php: * Events: BeforeSaveDiscussion, AfterSaveDiscussion. applications/vanilla/models/class.discussionmodel.php: $this->FireEvent('BeforeSaveDiscussion'); applications/vanilla/models/class.discussionmodel.php: $this->FireEvent('AfterSaveDiscussion'); $ grep -E "(Discussion|Comment)Save" applications/ -R applications/vanilla/controllers/class.postcontroller.php: $this->FireEvent('AfterDiscussionSave'); applications/vanilla/controllers/class.postcontroller.php: $this->FireEvent('AfterCommentSave');
  • TimTim Vanilla Staff
    Yeah I saw that when I searched.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • TimTim Vanilla Staff
    Remove the & from $Sender. Are you doing this in a plugin? Does the plugin extend GDN_Plugin? Is it enabled?

    There is no reason for a single event to "stop working".

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Well...

    Proper name is CommentModel_BeforeSaveComment_Handler :)
  • TimTim Vanilla Staff
    Depends what event you're trying to fire. You had PostController so I figured you had that part right :p

    Vanilla Forums COO [GitHub, Twitter, About.me]

Sign In or Register to comment.