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.

Using a Custom Event - plugin problem

LincLinc Detroit Admin
edited December 2009 in Vanilla 2.0 - 2.8
So I added a custom event to the login function in class.usermodel.php:
public function ValidateCredentials($Email = '', $ID = 0, $Password) { $this->FireEvent('BeforeValidateCredentials');
Then I make a plugin (and enable it) that starts like this:
class VbulletinPassword implements Gdn_IPlugin { public function UserModel_BeforeValidateCredentials_Handler(&$Sender) {
But nothing I put inside the function is firing at login. What am I doing wrong?

Comments

  • edited December 2009
    Hi @Lincoln,

    I changed my CallEventHandler function in class.pluginmanager.php to dump its calls to a raw text file (dirty I know!)...

    Anyway, it appears that it'll try and call both:

    gdn_usermodel_beforevalidatecredentials_handler base_beforevalidatecredentials_handler

    So a function declared like:

    public function Gdn_UserModel_BeforeValidateCredentials_Handler(&$Sender) { // ... }

    Will get called... I'm not sure if this is expected functionality of having to include the Gdn_ prefix?

    I found that when I tried to override the SearchModel I had to install it as two aliases, both Gdn_SearchModel and SearchModel as was used differently in different areas.

    Hope this helps!

    Cheers.

    Ben
  • LincLinc Detroit Admin
    @benno, thanks! I was using VanillaCommentReplies as an example, and it doesn't use the Gdn_ prefix for its method names... but maybe it was wrong to assume that plugin still works! ;) I will give that a shot.

    I've used mail() to debug so dumping to text file seems positively clean to me, haha.
  • No worries, documentation and examples are a little bit thin at the moment, and maybe dated, which is understandable given that its still very early alpha.

    I'm tempted to draft up a few bits to test various parts of the plugin architecture when I get a few minutes to spare. For instance I'm having to overwrite both SearchModel and Gdn_SearchModel in order to capture new items (posts/comments) from Vanilla, plus remain compatible with the search controller in garden as it gets called differently.
Sign In or Register to comment.