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.

Looking for a way to hide the "Invitations" link on the Profile page

DoyceTDoyceT Model Questioner ✭✭✭

On my forum (2.1 stable, default theme) I'd like to remove the "invitations" link from the Profile page side bar.

In short, the only way new users get set up on the forum are when the Registrar (admin-permissions) sets them up in the dashboard.

The easy way to make the Invitations link disappear is to change the forum authentication to "Connect", but this has the undesirable (but understandable) side effect of disabling user's ability to change their passwords.

No users have the ability to issue invitations, so having that link on the sidebar is confusing to them, and I'd like to get it off there, basically.

Tagged:

Comments

  • peregrineperegrine MVP
    edited June 2014

    try this in a plugin or add it to your themehooks.

    either will work.

    set the invitations to 0 each role you don't want the Invitation link showing.

    public function ProfileController_AddProfileTabs_Handler($Sender) {
          $User =  $Sender->User;
          if ($User->CountInvitations < 1) {
           unset($Sender->ProfileTabs['Invitations']);
           }
          }
    

    or if you only want admin (the person who can edit and add users) to see invitations link

    public function ProfileController_AddProfileTabs_Handler($Sender) {
          $IsAdmin = Gdn::Session()->CheckPermission('Garden.Users.Edit'); 
          if (!$IsAdmin) {
          unset($Sender->ProfileTabs['Invitations']);
           }
          }
    

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

  • DoyceTDoyceT Model Questioner ✭✭✭
    edited June 2014

    Worked perfectly, peregrine, thanks!

    For the sake of a complete record (and those who might want it later) I created default.php in /plugins/HideInvitationsLink containing the following:

    <?php if (!defined('APPLICATION')) exit();
      $PluginInfo['HideInvitationsLink'] = array(
       'Name' => 'Hide Invitations Link',
       'Description' => 'This plugin hides the Invitations link on the Profile page side bar for any user with Invitations Per Month set to None under Dashboard/Registation.',
       'Version' => '0.1',
       'Author' => "doycet",
       'AuthorEmail' => 'doyce.testerman@gmail.com',
       'AuthorUrl' => 'http://vanillaforums.org/discussion/comment/210564'
    );
    
    class HideInvitationsLinkPlugin extends Gdn_Plugin {
    
    public function ProfileController_AddProfileTabs_Handler($Sender) {
        $User = $Sender->User;
        if ($User->CountInvitations < 1) {
        unset($Sender->ProfileTabs['Invitations']);
        }
        }
    }
    

    I like this functionality - it's a nice way to clean cruft out of a user's page.

  • this was specifically designed for your circumstances, only the admin invites. However the routine as shown will not allow the admin to see the invitations page if they have 0 invitations and want to uninvite someone.

    In your case, it might be better to use

    public function ProfileController_AddProfileTabs_Handler($Sender) {
         // routine to remove invitations link for everyone but admins and moderators.  
    
          $Session = Gdn::Session();
         if ($Session->User->Admin || $Session->CheckPermission('Garden.Moderation.Manage')) {
    
       //  use  alternative conditional  for only admins  if ($Session->User->Admin {
       //  just leave it be for admins and moderators , easier for me to understand without negation   
         } else {
           // everyone  else delete invitations link from profile since they won't be inviting
          unset($Sender->ProfileTabs['Invitations']);
           }
          }
    

    so the admin can uninvite. if you wanted the moderator to also uninvite and see invitations you could

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

  • DoyceTDoyceT Model Questioner ✭✭✭
    edited June 2014

    We actually don't use invitations at all - not even the admin does invites.

    For each new student, we create a Role, then create a User and attach that user's Role to the User. The student is emailed notification when the User is created, which functions as an invitation, I suppose, though it's not using the invitation function.

    Pretty much the only users assigned communal roles are Alumni and non-faculty staff. If there's ever a problem in the code with a forum using 200+ roles, I'll probably be the guy who finds it. :(

  • peregrineperegrine MVP
    edited June 2014

    well if you never want to see invites, for any role this is all you need.

    public function ProfileController_AddProfileTabs_Handler($Sender) {
    unset($Sender->ProfileTabs['Invitations']);
    }
    

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

  • DoyceTDoyceT Model Questioner ✭✭✭

    Cool. I'm filing that one away...

  • peregrineperegrine MVP
    edited June 2014

    why check count etc. if you don't need to. nanoseconds faster. :)

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

  • DoyceTDoyceT Model Questioner ✭✭✭

    Mostly, I'd like to leave the check in there in case I do need to turn on invites later - instead of needing to rewrite the code, I just need to change the admin Invites to some value other than none. :)

  • peregrineperegrine MVP
    edited June 2014

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

  • DoyceTDoyceT Model Questioner ✭✭✭

    Should I... I'm not sure what you're telling me to do with that link. :)

  • peregrineperegrine MVP
    edited June 2014

    if you have any add-ons tht you downloaded from github or the add-ons sections and they work in vanilla 2.1 if you don't mind adding to the list that would be cool. Even if they are repeats. and perhaps you already added them, if so, sorry for pestering you.

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

  • DoyceTDoyceT Model Questioner ✭✭✭

    No problem. I'll run through and add some stuff. :)

Sign In or Register to comment.