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.

How to hook into an event in theme?

peterlupeterlu New
edited February 2019 in Vanilla 2.0 - 2.8


Is there a way to create an addon, so I can hook into event "AfterSignIn"? Is there a code example to do so?

I want to test something like, after user logs in, php runs die('testing') :)



  • R_JR_J Ex-Fanboy Munich Admin

    I've just created a simple and quite useless starter plugin, that you can use to get going.

    In that plugin you have to create a new method. If you read through the documentation you might find a pargraph about events. Since "AfterSignIn" is fired in the EntryController, you need to insert a method called "entryController_afterSignIn_handler".

    Instead of dumping like you've planned to, I would recommend something less drastic which would require to have phpMyAdmin or similar opened in parallel.

    public function entryController_afterSignIn_handler($sender, $args) {
       Gdn::set('Debug', dbencode(array_keys($args)));

    That would write a line to the GDN_UserMeta table where you can look up what happened without interrupting the login process.

    $args are all the EventArguments that are filled before the event is fired. If you want to handle something, those args are most probably of interest for you.

  • charrondevcharrondev Developer Lead (PHP, JS) Montreal Vanilla Staff

    Relavent documentation here:

    There are a few examples as well.

Sign In or Register to comment.