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.

UserModel_AfterGetID_Handler

R_JR_J Ex-FanboyMunich Admin

Please take a look at the attached screenshots and at the code below:

   function UserModel_AfterGetID_Handler($Sender) {
      $UserID = $Sender->EventArguments['User']->UserID;
      if(!isset($UserID)) {
         decho($Sender->EventArguments['LoadedUser']['UserID']);
         $Gender = Gdn::SQL()
            ->Select('Gender')
            ->From('User')
            ->Where('UserID', $Sender->EventArguments['LoadedUser']['UserID'])
            ->Get()
            ->FirstRow(DATASET_TYPE_OBJECT)
            ->Gender;
         echo "<span class=\"Gender_{$Gender}\" />";
      }
   } 

The event is fired too often for my purpose. Could anybody point me to a way just to react on them, when they are fired from discussion/comment controller?

For explanation: I am searching for an event in Vanilla 2.1 where I can place HTML before the username is shown in discussion and comment and I've only found AfterGetID to be suitable. But it is used too often to insert my HTML every time that event is fired...

Comments

  • peregrineperegrine MVP
    edited September 2013

    not the answer you wanted... but

    I knew you were going to use that to try to precede the gender , instead of authorinfo :).

    personally, I think it looks better after the name,

    try css absolute positioning with authorinfo.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • R_JR_J Ex-Fanboy Munich Admin

    Well, that's another solution: if I can not make 2.1 look like 2.0.18.8, I could try changing the look for 2.0.18.8. I'll look for that because it seems to be a lot easier

  • Take a look at the RoleTitle plugin. Maybe there's also a plugin that gives the username a color based on his role.

    There was an error rendering this rich post.

  • I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • R_JR_J Ex-Fanboy Munich Admin

    @UnderDog: I'd like to add something to the username but the RoleTitle plugin adds to userinfo. I need an event that is fired before the username is displayed.

    @peregrine: I've commented over there to give feedback to your suggestion

  • hgtonighthgtonight ∞ · New Moderator

    Using a model event handler to display information is bad practice, in my opinion. You are taking something that is purposefully split from the presentation and hacking presentation code back in to it.

    At least that is what I am reading in to it.

    That said, decho $Sender and try to find differences. You probably won't find much since you are in the model, not the controller or the view.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited September 2013

    @hgtonight said.
    Using a model event handler to display information is bad practice, in my opinion. You are taking something that is purposefully split from the presentation and hacking presentation code back in to it.

    the two of us agree on this point :). You said it in better words,

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.