# Detect when a user leaves meeting?

**URL:** <https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751>\
**Category:** Web\
**Created:** [February 7, 2021, 8:13pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751 "2021-02-07T20:13:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bferster](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bferster/32/16820_2.png) [@bferster](https://devforum.zoom.us/u/bferster)\
**Post date:** [February 7, 2021, 8:13pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/1 "2021-02-07T20:13:03Z")

</div>

**Description**

I want to detect when the user in the _current_ client leaves the meeting by clicking on the red button. I’ve tried these two handlers, but **onUserLeave** never fires and **onMeetingStatus** fires only on initing, not closing:

```
 ZoomMtg.inMeetingServiceListener('onUserLeave', function (data) {
    console.log(data);
  });

   ZoomMtg.inMeetingServiceListener('onMeetingStatus', function (data) {
    // {status: 1(connecting), 2(connected), 3(disconnected), 4(reconnecting)}
    console.log(data);
  });

```

**Which version?**  
WebSDK 1.90

**Device (please complete the following information):**

- Device:PC
- OS: Windows
- Version:10
- Browser: Chrome

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [February 8, 2021, 10:49pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/2 "2021-02-08T22:49:27Z")

</div>

Hey @bferster,

Thank you for reaching out to the Zoom Developer Forum. Good question! The `onUserLeave` event will only fire for users that are not the host as when the host ends the meeting, the page redirects before it has a chance to fire.

The same is true when it comes to `onMeetingStatus`. For participants of the meeting, you’ll see this event fire. However, the host won’t see this event fire before the page redirects at the end of the meeting.

You can use these methods to detect when a user leaves it just may not work for the host. When it comes to the host, you may want to look into the [meeting.started](https://marketplace.zoom.us/docs/api-reference/webhook-reference/meeting-events/meeting-started) or [meeting.participant\_joined](https://marketplace.zoom.us/docs/api-reference/webhook-reference/meeting-events/participant-joined-meeting) webhooks.

Let me know if that helps.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![nvivot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/nvivot/32/4489_2.png) [@nvivot](https://devforum.zoom.us/u/nvivot)\
**Post date:** [February 9, 2021, 1:56am UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/3 "2021-02-09T01:56:39Z")

</div>

@MaxM

Have you fixed InMeetingListeners event according to what i reported here ?

> [@Blocking inconsistencies between inMeetingServiceListener() data and getCurrentUser() data](https://devforum.zoom.us/t/blocking-inconsistencies-between-inmeetingservicelistener-data-and-getcurrentuser-data/39645):
>
> Description I wanted to subscribe to the events when a user is put on hold and then put back into a meeting to see if i can customize my application behavior. I faced several issues and tried to find workaround but in the end the way the SDK is designed now make it impossible to react correctly on an event. I won’t enter into the details, so long story short, if you want to apply a behavior on a specific user when he receive an event, and because the zoom web SDK broadcast a single event to al…

If not, can you please re open this topic and provide an update ?

---

<div class="post-metadata">

**Author:** ![bferster](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bferster/32/16820_2.png) [@bferster](https://devforum.zoom.us/u/bferster)\
**Post date:** [February 9, 2021, 2:29pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/4 "2021-02-09T14:29:05Z")

</div>

I guess that makes sense. I solved the issue for now by handling a click on the Leave button, but that’s somewhat of a kluge

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [February 10, 2021, 7:55pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/5 "2021-02-10T19:55:43Z")

</div>

Hey @bferster,

For the time being, that’s a good solution. You can also [create an event listener](https://stackoverflow.com/questions/3888902/detect-browser-or-tab-closing) for the `beforeUnload` and the `unload` events.

That should make sure that when the page is redirected or tab/browser is closed for the host, you can perform any actions that you need.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [February 10, 2021, 7:56pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/6 "2021-02-10T19:56:15Z")

</div>

Hey @nvivot,

I’ve re-opened and updated that topic.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![bferster](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bferster/32/16820_2.png) [@bferster](https://devforum.zoom.us/u/bferster)\
**Post date:** [February 10, 2021, 8:58pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/7 "2021-02-10T20:58:24Z")

</div>

Thanks. I’m already doing that, When the user clicks the button, I send a cross-domain message to the caller to close the window.

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [February 11, 2021, 9:48pm UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/8 "2021-02-11T21:48:40Z")

</div>

Hey @bferster,

I’m glad to hear you found a solution that works for you! If you would like this feature to be considered for a future release, I recommend posting in the #feature-requests category.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [March 14, 2021, 7:49am UTC](https://devforum.zoom.us/t/detect-when-a-user-leaves-meeting/42751/9 "2021-03-14T07:49:03Z")

</div>

Closed on March 14, 2021, 7:49am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
