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.

Override a Before Event

Hi, I'm new to these forums. I am trying to extend the Voting plugin without touching someone else's code in the event an update is provided. Example -

public function DiscussionController_BeforeCommentMeta_Handler($Sender) { //do stufff }

is an essential method that gets called with FireEvent('BeforeCommentMeta')
I haven't verified that that is actually how it's called but from what I've seen, I think it is...

I would like to rewrite this method to do some custom things without going and changing that method since Vanilla has the notion of Override. However, this simply doesn't work...

public function DiscussionController_BeforeCommentMeta_Handler_Override($Sender){ //do custom stuff }

I've checked the basics, (i.e. made sure my plugin was enabled) but my method never gets called. If I take off the "Override", then both methods are called as expected. Any help in the matter would be a lifesaver. Thanks!


  • Options
    LincLinc Detroit Admin
    edited March 2011
    Here's @Tim's suggestion: Try making a new plugin that inherits the class from the Voting plugin and then name it the same as that method. Pretty sure this is an untested "hey try this" idea so let us know if it works.

    //edit: Removed comment about needing to have both plugins enabled because I'm unsure, thinking about it more, exactly how it would work. Maybe you'd need to manually use Gdn::Factory to call the Voting class rather than enable it. Expect this to be tricky and annoying to figure out.

    Otherwise, just hack your own copy of the Voting plugin. It's not nearly as bad as hacking core.
Sign In or Register to comment.