Hack to enable invitations for Trust level 1 users


(Non-technical User) #1

My community is based on invitations and I would really like to turn on the feature of inviting friends for my trust level 1 members. I have a lot of members in trust level 1 and its going to take some time before they can get to level 2 to be able to invite their friends. But since no new members are joining these days, less topics are being posted and there’s less engagement overall. So my trust level 1 members have also slowly stopping to visit. Am afraid the community will die like this unless I enable my trust level 1 members to invite their friends to their topics. And it a request that’s coming in from many users for them to have the ability to invite.


(Jeff Atwood) #2

So promote them to trust level 2? Then they will have invites.


(Non-technical User) #3

Yes, that’s the only way I have but I do not want to do that unnecessarily and also give them extra privileges that they haven’t earned. It would be nice to have a setting to set the trust level for the invite feature. For now is there any other hack I can use on or within the app to get this done?


(Jeff Atwood) #4

Well, if you trust them enough to send out invites, and ultimately achieve trust level 2 organically on their own to do so … why wouldn’t you trust them enough to grant them TL2 now? I’m not following this train of logic. :train2:


(Mittineague) #5

If the goal is to increase the member base quickly, it might be better to lower the TL2 requirements than to simply grant TL2 to everyone

tl2 requires topics entered - 20
How many topics a user must enter before promotion to trust level 2.
tl2 requires read posts - 100
How many posts a user must read before promotion to trust level 2.
tl2 requires time spent mins - 60
How many minutes a user must read posts before promotion to trust level 2.
tl2 requires days visited - 15
How many days a user must visit the site before promotion to trust level 2.
tl2 requires likes received - 1
How many likes a user must receive before promotion to trust level 2.
tl2 requires likes given - 1
How many likes a user must cast before promotion to trust level 2.
tl2 requires topic reply count - 3
How many topics user must reply to before promotion to trust level 2.

TBH I don’t see where any of those are that out of reach or unreasonably high


(Non-technical User) #6

I want the process of gaining trust level 2 to happen naturally with users participating and gaining the level. My only requirement is they be able to invite others to their current topics and the forum in general without the need to wait until they finish reading 100 posts or all that listed above. I understand it is not unreasonably high but in my case, I also feel the time this would require is going to cost me user interest as well as new members. I am guesstimating out of 100 users at trust level 1, only 10 or so are going to stick around long enough to gain trust level 2. The others are going to just drop off. But before that, I would be interested if they can help invite a couple or so users themselves out of which a few may help build my community by participating well. And so on…

If there’s something I can do now to get my users at trust level 1 to use the invite feature without having to promote them to level 2 myself, let me know.


(Christoph) #7

Same here! This would be a really great feature to have, given that new invites are what you need most of all on new forums…


(Rogue ) #8

Why was this not a feature?


(Vinoth Kannan) #9

To enable Invites to TL1 users you can create a plugin. All you have to do is monkey patching the hard-coded TL value in below code


(Christoph) #10

Could you give some more hints for the plugin noobs among us? I don’t expect a full tutorial (as that already exists), but perhaps some pointers as to where to start? (So far, the closest I have gotten to creating a plugin was to fork an existing one and change some of its settings…)


(Vinoth Kannan) #11
after_initialize do
  Guardian.class_eval do
    def can_invite_to_forum?(groups=nil)
      authenticated? &&
      (SiteSetting.max_invites_per_day.to_i > 0 || is_staff?) &&
      !SiteSetting.enable_sso &&
      SiteSetting.enable_local_logins &&
      (
        (!SiteSetting.must_approve_users? && @user.has_trust_level?(TrustLevel[1])) ||
       is_staff?
      ) &&
      (groups.blank? || is_admin?)
    end
  end
end

I guess this is the code you need. Put it in plugin.rb file. Since I am not in PC I didn’t tested it.


(Alan Tan) #12

Is there a reason why we don’t move this into a site setting? Monkey patching isn’t a good way to go about doing this.


(Mittineague) #13

Would it need a new setting or would testing for the existing bootstrap mode be good enough?


(Christoph) #14

I think activating invites for TL1 users in bootstrap mode is an excellent idea but if there is no

I think that should also be done.

tl;dr Bootstrap mode: yes; site setting: yes


(Christoph) #15

Before I start messing up my instance: are there any plans for making this available as a site setting in the near future?


(Alan Tan) #16

It’ll be @codinghorror’s call here.


(Jeff Atwood) #17

Not enough requests for it from paying customers at this time.


(Christoph) #18

Thanks to @vinothkannans’s primer above, I managed to put together the discourse-TL1-invites plugin. :tada: My first one, yeay! :sunglasses: And the best thing is: it works (from what I can tell so far).

The only thing I am a bit unsure about is that I am not 100% sure whether I am allowing TL1 users anything apart from forum invites and topic invites here:

The only change I made is obviously the trustlevel in line 37, but I don’t quite grasp, what all the possible objects are that TL1 users can do invites for…


Adapt github changes to my own site
(Christoph) #19

Just a quick heads-up for anyone copying and pasting that code: unless I misunderstood something, that line should now read

return false unless SiteSetting.enable_personal_messages?