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.
Options

User event hooks / handler

martin28martin28 New
edited July 2018 in Vanilla 2.0 - 2.8

Hi Team,
I would like to know what is the best approach to hook the user events (like before/after user login/register) in plugin for vanilla 2.6. Currently i'm using (ex. entryController_signin_handler) works with Vanilla 2.2. I tried (ex. userModel_afterSignIn_handler) which appears to work with Vanilla 2.6.

Do we have list of hooks for Vanilla 2.6 or version after 2.2?

TIA

Comments

  • Options
    BleistivtBleistivt Moderator

    There is no such list unfortunately.

    The best approach is to either examine plugins with similar functionality and examine which hooks they are using, or search the corresponding controller, model & views for fireEvent calls.

    For example, if you want to extend functionality in /discussions that would be class.discussionscontroller.php or class.discussionmodel.php.
    To find view hooks, look out for $this->render(...) to find out what view a controller method is using (or just search for a translation string or css class contained in the view).

  • Options

    Thanks @Bleistivt, I'm trying to hook in after register which I did successful using userModel_afterRegister_handler. My concern now is that the session only starts after login not after register. Does anyone tried starting GDN session after register?

    TIA

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    In the EntryController are several methods which handle the different registration methods. All of them contain lines similar to this:

     } elseif (!$authUserID) {
        $this->Form->setValidationResults($this->UserModel->validationResults());
    } else {
        // The user has been created successfully, so sign in now.
        Gdn::session()->start($authUserID);
    

    So as you can see, the session is started after the registration has successfully been finished. Does that answer your question?

  • Options

    Yes, many thanks @R_J I managed to add event after register in entryController using RegistrationSuccessful.

Sign In or Register to comment.