# Listing event invitees with email addresses

**URL:** https://meta.discourse.org/t/listing-event-invitees-with-email-addresses/399106
**Category:** Data & reporting
**Tags:** events, sql-query
**Created:** [March 23, 2026, 9:59pm UTC](https://meta.discourse.org/t/listing-event-invitees-with-email-addresses/399106 "2026-03-23T21:59:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [March 23, 2026, 9:59pm UTC](https://meta.discourse.org/t/listing-event-invitees-with-email-addresses/399106/1 "2026-03-23T21:59:35Z")

</div>

> 🔖 This is a [Data Explorer](https://meta.discourse.org/t/32566) SQL query that retrieves a list of all users who have RSVP’d to a specific event, along with their primary email addresses. It’s useful for event coordinators who need attendee contact information for follow-ups, reminders, or external communications.
> 
> 🙋 Required user level: Administrator
> 
> :discourse2: This query requires the [Calendar (and Event) plugin](https://meta.discourse.org/t/discourse-calendar-and-event/97376) to be enabled.

## What this query does

If you run events on your Discourse site using the [Calendar (and Event) plugin](https://meta.discourse.org/t/discourse-calendar-and-event/97376), you may need a way to get a full attendee list with email addresses — for example, to send a pre-event briefing, share logistics, or follow up after the event.

The built-in “Export event” feature in the event menu downloads a list of RSVPs, but it’s delivered as a zipped file via personal message. This [Data Explorer](https://meta.discourse.org/t/32566?silent=true) query gives you a faster, on-screen alternative that includes each attendee’s primary email address, and allows you to export the results directly to CSV or JSON.

The query returns all users who have responded to a given event (regardless of whether they chose “Going”, “Interested”, or “Not Going”), sorted alphabetically by username.

## SQL query

```sql
-- [params]
-- integer :event_topic_id = 23338

SELECT 
  u.id AS user_id,
  u.username,
  u.name,
  e.email
FROM users u
JOIN user_emails e ON u.id = e.user_id
JOIN discourse_post_event_invitees invitees ON u.id = invitees.user_id
JOIN posts p ON p.id = invitees.post_id
WHERE e.primary = true
AND p.topic_id = :event_topic_id
ORDER BY u.username

```

## Parameter

| Parameter | Type | Description |
| --- | --- | --- |
| `:event_topic_id` | Integer | The topic ID of the event you want to pull invitees from. You can find this in the URL of the event topic — for example, in `discourse.example.com/t/my-event-topic/23338`, the topic ID is `23338`. |

## How the query works

This query pulls data from four database tables and combines them to produce a single list:

1. **`users`** — Contains basic user profile information such as username and display name.
2. **`user_emails`** — Stores email addresses associated with each user. A user can have multiple email addresses, so the query filters to only the **primary** email using `e.primary = true`.
3. **`discourse_post_event_invitees`** — Records every user who has responded to an event (by clicking “Going”, “Interested”, or “Not Going”). Each record links a user to the post that contains the event.
4. **`posts`** — Connects the event’s post to its parent topic, allowing you to look up invitees by topic ID rather than needing to know the internal post ID.

The `JOIN` statements link these tables together so that only users who appear in the invitees list for the specified event topic are included. Results are sorted alphabetically by username.

## Example results

| user\_id | username | name | email |
| --- | --- | --- | --- |
| 42 | alice\_m | Alice Martinez | [alice@example.com](mailto:alice@example.com) |
| 87 | bob\_jones | Bob Jones | [bob@example.com](mailto:bob@example.com) |
| 15 | carol\_w | Carol Wu | [carol@example.com](mailto:carol@example.com) |
| 63 | david\_k | David Kim | [david@example.com](mailto:david@example.com) |

## Filtering by RSVP status

The query above returns _all_ invitees regardless of their RSVP status. If you only want users who marked themselves as “Going”, you can add a status filter to the `WHERE` clause. The `status` column in the `discourse_post_event_invitees` table uses these values:

| Status code | Meaning |
| --- | --- |
| `0` | Going |
| `1` | Interested |
| `2` | Not Going |

For example, to return only users who are “Going”, add `AND invitees.status = 0` to the `WHERE` clause:

```sql
-- [params]
-- integer :event_topic_id = 23338

SELECT 
  u.id AS user_id,
  u.username,
  u.name,
  e.email
FROM users u
JOIN user_emails e ON u.id = e.user_id
JOIN discourse_post_event_invitees invitees ON u.id = invitees.user_id
JOIN posts p ON p.id = invitees.post_id
WHERE e.primary = true
AND p.topic_id = :event_topic_id
AND invitees.status = 0
ORDER BY u.username

```

You can also display the RSVP status as a readable label instead of a number by adding a `CASE` expression:

```sql
CASE 
  WHEN invitees.status = 0 THEN 'Going'
  WHEN invitees.status = 1 THEN 'Interested'
  WHEN invitees.status = 2 THEN 'Not Going'
END AS rsvp_status

```

## Running the query

1. Go to **Admin \> Plugins \> [Data Explorer](https://meta.discourse.org/t/32566?silent=true)** (or navigate to `/admin/plugins/discourse-data-explorer`).
2. Click the **+** button to create a new query.
3. Give the query a name (e.g., “Event invitees with emails”).
4. Paste the SQL into the query editor.
5. Click **Run** , then enter the topic ID of your event when prompted.
6. To download the results, click the **CSV** or **JSON** button after the query has finished running.

> ℹ The email column contains sensitive personal data. Take care when exporting or sharing the results, and make sure your use of this data complies with your community’s privacy policy and any applicable data protection regulations.

## Common issues and solutions

| Issue | Solution |
| --- | --- |
| The query returns zero results | Double-check that the topic ID is correct and that users have actually RSVP’d to the event. You can verify by visiting the event topic and checking the attendee list. |
| “relation discourse\_post\_event\_invitees does not exist” error | The [Calendar (and Event) plugin](https://meta.discourse.org/t/discourse-calendar-and-event/97376) is not installed or not enabled. This query requires the plugin to be active. |
| Duplicate rows appear in results | If a user has multiple email records flagged as primary (uncommon, but possible), you may see duplicates. Adding `DISTINCT` after `SELECT` can resolve this. |
