# Invite badges from inviting yourself

**URL:** https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143
**Category:** UX
**Tags:** invites
**Created:** [February 14, 2022, 5:04pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143 "2022-02-14T17:04:14Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [February 14, 2022, 5:04pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/1 "2022-02-14T17:04:14Z")

</div>

# Description and Evidence

Recently in [2.9.0beta2](https://meta.discourse.org/t/2-9-0-beta2-security-fix-and-more/218086) users that already have an account can click invite links. But I generated invite links can click them it said I invited myself and because I am TL2+ and I clicked 5 different invite links of mine I received the [Champion badge](https://community.replit.com/badges/27/champion?username=ethan_maser_coding). You can see a screenshot below of it below. These are in the [Replit EDU forums](https://community.replit.com/) and you can view my profile [here](https://community.replit.com/u/ethan_maser_coding/summary).

 ![Screenshot 2022-02-14 11.03.38](https://global.discourse-cdn.com/meta/original/3X/7/a/7a28be0800ec6c6b2e0dd132017817e66002b70d.png)

I also made an invite link on the [Codecademy forums](https://discuss.codecademy.com/) and it says I invited myself there also that you can see below. View my profile [here](https://discuss.codecademy.com/u/ethanmasterprogram/summary).

 ![Screenshot 2022-02-14 11.53.39](https://global.discourse-cdn.com/meta/original/3X/c/a/caaeb3951c2e192fb997283a5712b2b95ec902c8.png)

# Repro steps

Reach TL2+ (by default) make invite links that you then click. It will say that you invited yourself on your profile and that you accepted your invite as shown above. And if you enough invite links you will receive the Campaigner and Champion badges.

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [February 14, 2022, 5:15pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/2 "2022-02-14T17:15:12Z")

</div>

Works for me here too. Now my profile says I was invited by myself.

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [February 14, 2022, 5:19pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/3 "2022-02-14T17:19:09Z")

</div>

And you should receive the promoter badge. (Forgot to mention it in the original post because I already had it before this)

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [February 14, 2022, 7:24pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/4 "2022-02-14T19:24:30Z")

</div>

Thanks for pointing this out! When designing this feature, I forgot to think like an evil person. 🦹

@dan any thoughts on how to fix this issue?

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [February 14, 2022, 7:42pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/5 "2022-02-14T19:42:00Z")

</div>

I personally never looked at the code for discourse but something like this might would work. (this is in JS because that’s what I know best)

```javascript
if (invter != invitee) {
  inviter_count++
}

```

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [February 18, 2022, 9:12pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/6 "2022-02-18T21:12:49Z")

</div>

This bug is now fixed. Thanks again @not-ethan for reporting it! If you notice anything at all wrong with the invite system, do let us know. We’re actively working on it.

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [February 18, 2022, 9:13pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/7 "2022-02-18T21:13:42Z")

</div>



---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [March 15, 2022, 8:14am UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/8 "2022-03-15T08:14:22Z")

</div>



---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [March 15, 2022, 8:15am UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/9 "2022-03-15T08:15:26Z")

</div>

Reopening because I got a PM that I lost track of from @not-ethan. @dan if it’s not too much trouble would you mind assisting?

> Can I have a link to the commit or PR for the fix? I’m just curious as to what the fix was

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [March 25, 2022, 2:46am UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/10 "2022-03-25T02:46:00Z")

</div>

@tobiaseigen @dan think I found the PR [FIX: Do not increase invite count for current user by udan11 · Pull Request #15952 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/15952)

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [March 25, 2022, 5:55am UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/11 "2022-03-25T05:55:30Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 17, 2022, 10:09pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/12 "2022-09-17T22:09:14Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 18, 2022, 7:07am UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/13 "2022-09-18T07:07:43Z")

</div>

Reopened on the the request of @not-ethan. Has there been a regression somehow?

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [September 18, 2022, 3:25pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/14 "2022-09-18T15:25:31Z")

</div>

After some extra testing, I am only experiencing this on Replit Ask:

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/8/0/b809889ff39fb2c092f44bad53e2ee1b055eb9b4.png)  
But not on here meta or on another forum, all it says is that `Ethan accepted your invitation` but does not grant the badges.

---

<div class="post-metadata">

### Author: ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)
#### Post date: [September 18, 2022, 4:26pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/15 "2022-09-18T16:26:40Z")

</div>

Never mind I just got the badges here in meta and on that other forum. It took like 12 hours thought.

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/1/9/9191b3cb58fe024bdba0f7c645716af209e8cd31.png)

---

<div class="post-metadata">

### Author: ![khenmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/khenmu/32/108976_2.png) [@khenmu](https://meta.discourse.org/u/khenmu)
#### Post date: [September 18, 2022, 4:46pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/16 "2022-09-18T16:46:39Z")

</div>

Can confirm.

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/3/c/f3c7f383845bfad58b08ba846488ebace3162fbc.jpeg)

---

<div class="post-metadata">

### Author: ![urias](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/urias/32/284277_2.png) [@urias](https://meta.discourse.org/u/urias)
#### Post date: [December 4, 2022, 12:01pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/18 "2022-12-04T12:01:10Z")

</div>

Hey people,

there’s a bug in which you can create an invite code and redeem it yourself, doing this you can get the invite badges, which is annoying. This was mentioned by @not-ethan and a pull request was made, but the bug is still active. My idea was if someone uses an invite code for the web, but that person is logged it make the code fail!

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [January 5, 2023, 3:37pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/19 "2023-01-05T15:37:18Z")

</div>

Thanks for bringing this up again, Urias. We are seeking to not touch the invite system too much at the moment, because it is complex and making changes can have unintended and unplanned consequences.

> [@not-ethan](#):
>
> ![image](https://global.discourse-cdn.com/meta/original/4X/b/8/0/b809889ff39fb2c092f44bad53e2ee1b055eb9b4.png)

Is there any way we could sidestep this problem by changing how the badge is awarded? E.g. if the person redeeming the invite is already a member, do not award the campaigner badge to the person who created the invitation?

This seems to me to be a problem that likely has existed for a long time and gone unnoticed. Another answer might be to treat this as “do nothing, works by design” and leave it to community moderators to address it if they are concerned by people abusing this method to get more badges.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [January 5, 2023, 4:13pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/22 "2023-01-05T16:13:12Z")

</div>

> [@tobiaseigen](#):
>
> Is there any way we could sidestep this problem by changing how the badge is awarded? E.g. if the person redeeming the invite is already a member, do not award the campaigner badge to the person who created the invitation?

My SQL probably needs checking 🙂, but I believe you could add this line to the badge query to stop it being granted to people who have invited themselves - `AND i.invited_by_id <> u2.id`

So something like this:

```plaintext
SELECT u.id user_id, current_timestamp granted_at 
FROM users u 
WHERE u.id IN (
  SELECT invited_by_id 
  FROM invites i 
  JOIN invited_users iu ON iu.invite_id = i.id 
  JOIN users u2 ON u2.id = iu.user_id 
  WHERE i.deleted_at IS NULL
  AND i.invited_by_id <> u2.id
  AND u2.active 
  AND u2.trust_level >= 0 
  AND u2.silenced_till IS NULL 
  GROUP BY invited_by_id 
  HAVING COUNT(*) >= 1 
) AND u.active AND u.silenced_till IS NULL AND u.id > 0 AND
(:backfill OR u.id IN (:user_ids) ) 	

```

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [January 5, 2023, 4:16pm UTC](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143/23 "2023-01-05T16:16:06Z")

</div>

Cool! I haven’t played with the badge system in a while but looking now I don’t see the invites related badges in the admin\>badges UI. Maybe these are system badges that have to be edited in core discourse?

[Next page](https://meta.discourse.org/t/invite-badges-from-inviting-yourself/218143.md?page=2)
