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.

[Yet Another Gamification Application] How to add ranks as titles

Hello. As with this forum, for Yaga, how do you use Ranks as titles? For example, a member was just promoted to Level 3, but I want it to show Level 3 next to the title. Is this possible?

Tagged:

Comments

  • The rank id is attached to the user object.

    You can get the rank name from the rank model with this snippet:

    $RankModel = Yaga::RankModel();
    $Rank = $RankModel->GetByID($User->RankID);
    
    echo $Rank->Name;
    

    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.

  • And where is it added @hgtonight?

  • Ranks are set up through the rank controller, i.e. /yaga/rank.

    I am confused as to where you want to add it.

    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.

  • edited January 2014

    @hgtonight I don't know where to add the code you gave me. What file is it added into?

  • @hgtonight Do you mean add the code you gave me in /applications/yaga/ranks/class.rankcontroller.php

  • No. You can use that code in any plugin in any hook you want. All you need is access to the user object.

    For example, if you wanted to show the Rank name next to the user name like the role title plugin, you could use this plugin hook:

    public function DiscussionController_AuthorInfo_Handler($Sender) {
      // Get the user object from the controller, I am just guessing with this line
      $User = $Sender->User;
    
      $RankModel = Yaga::RankModel();
      $Rank = $RankModel->GetByID($User->RankID);
      echo Wrap($Rank->Name, 'span', array('class' => 'MItem RankName'));
    }
    

    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.

  • edited January 2014

    @hgtonight I want it next to the Title, like here at vanillaforums.org | Also, where is the user object? class.rankcontroller.php?

  • Yaga doesn't load a user object anywhere.

    Many controllers do. For example, the profile controller does. Where it is in the controller is left up to you to find out.

    Dump the $Sender object and start looking for it.

    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.

  • I think I will just assign a role. Thank you for your help, @hgtonight! I will look again when I have free time

  • UnderDogUnderDog MVP
    edited January 2014

    And this discussion is ... closed.... Kudos to hgtonight for his patience. @ilovetech next time you post a question about a plugin, post it on the Addon page, so it's attached to that plugin

    There was an error rendering this rich post.

This discussion has been closed.