How to hook into an event in theme?

peterlupeterlu New
edited February 21 in Vanilla 2.8 Help

Hi,

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') :)

Peter

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    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.


Sign In or Register to comment.