# Inside onUserJoin, every user returns false when calling isHost(), even for the host itself

**URL:** <https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547>\
**Category:** Windows\
**Created:** [September 21, 2023, 4:02pm UTC](https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547 "2023-09-21T16:02:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![oren.nahum1](https://avatars.discourse-cdn.com/v4/letter/o/ad7895/32.png) [@oren.nahum1](https://devforum.zoom.us/u/oren.nahum1)\
**Post date:** [September 21, 2023, 4:02pm UTC](https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547/1 "2023-09-21T16:02:49Z")

</div>

**Description**  
Inside the callback `onUserJoin` (from `IMeetingParticipantsCtrlEvent`), `pUserInfo->IsHost()` returns false for all users, even the host itself.  
Tried also to iterate over `GetParticipantsList()` (from `IMeetingParticipantsController`), got same result (all false).

**Which Windows Meeting SDK version?**  
5.14.5.15340

**To Reproduce(If applicable)**  
Steps to reproduce the behavior:

1. Have the SDK demo join any meeting.
2. Inside onUserJoin callback:

```auto
void CMeetingServiceMgr::onUserJoin(IList<unsigned int >* lstUserID, const wchar_t* strUserList)
{
	// print user name
	::log("INFO: MeetingServiceMgr::onUserJoin START ");

	if (lstUserID && m_pMeetingService)
	{
		int count = lstUserID->GetCount();
		for (int i = 0; i < count; i++)
		{
			int userId = lstUserID->GetItem(i);
			IUserInfo* pUserInfo = this->GetUserByUserID(userId);
			if (pUserInfo)
			{
				using convert_type = codecvt_utf8<wchar_t>;
				wstring_convert<convert_type, wchar_t> converter;
				auto uname = (wstring)pUserInfo->GetUserNameW();
				string str_uname = converter.to_bytes(uname);
				::log("user info:");
				::log(to_string(userId) + " " + str_uname);
				::log("isHost:");
				::log(std::to_string(pUserInfo->IsHost()));
			}
		}
	}

	auto pUsers = m_pUserCtrl->GetParticipantsList();
	if (!pUsers)
	{
		::log("Could not GetParticipantsList. Cannot get user id.");
	}

	for (auto i = 0; i < pUsers->GetCount(); i++)
	{
		auto user_id = pUsers->GetItem(i);
		auto pUser = this->GetUserByUserID(user_id);

		string current_user_name = WCharToString(pUser->GetUserNameW());
		::log("pUser->GetUserNameW():");
		::log(current_user_name);
		::log("isHost:");
		::log(std::to_string(pUser->IsHost()));
	}
}

```

**Logs**

```auto
2023-09-21 15:08:29.360 3612909816Chorus911183868F47829455DAED58668858A7184 INFO: CMeetingServiceMgr::onUserJoin START 
2023-09-21 15:08:29.360 3612909816Chorus911183868F47829455DAED58668858A7184 user info:
2023-09-21 15:08:29.360 3612909816Chorus911183868F47829455DAED58668858A7184 16778240 Oren Nahum
2023-09-21 15:08:29.361 3612909816Chorus911183868F47829455DAED58668858A7184 isHost:
2023-09-21 15:08:29.361 3612909816Chorus911183868F47829455DAED58668858A7184 0
2023-09-21 15:08:45. 98 3612909816Chorus911183868F47829455DAED58668858A7184 pUser->GetUserNameW():
2023-09-21 15:08:45. 98 3612909816Chorus911183868F47829455DAED58668858A7184 Oren Nahum
2023-09-21 15:08:45. 98 3612909816Chorus911183868F47829455DAED58668858A7184 isHost:
2023-09-21 15:08:45. 99 3612909816Chorus911183868F47829455DAED58668858A7184 0
2023-09-21 15:08:45. 99 3612909816Chorus911183868F47829455DAED58668858A7184 pUser->GetUserNameW():
2023-09-21 15:08:45. 99 3612909816Chorus911183868F47829455DAED58668858A7184 ZoomSDKDemo
2023-09-21 15:08:45. 99 3612909816Chorus911183868F47829455DAED58668858A7184 isHost:
2023-09-21 15:08:45. 99 3612909816Chorus911183868F47829455DAED58668858A7184 0

```

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

- Device: HP Zenbook
- OS: Windows 10

**Additional context**  
I need to know when the host joins so I can prompt him with `RequestLocalRecordingPrivilege` (from `IMeetingRecordingController`).

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [September 22, 2023, 4:37am UTC](https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547/2 "2023-09-22T04:37:21Z")

</div>

@Oren ,

I’m using the latest SDK, but I’m unable to replicate the issue.  
Could you try with an if else for IsHost() ?

```auto
IList<unsigned int>* meetingParticipantID = meetingService->GetMeetingParticipantsController()->GetParticipantsList();

if (meetingParticipantID && meetingService)
{
	int count = meetingParticipantID->GetCount();
	for (int i = 0; i < count; i++)
	{
		int userId = meetingParticipantID->GetItem(i);
		IUserInfo* pUserInfo = meetingService->GetMeetingParticipantsController()->GetUserByUserID(userId);
		if (pUserInfo)
		{

			
			printf("UserID %d\n", pUserInfo->GetUserID());
			printf("UserName %ls\n", pUserInfo->GetUserNameA());
			if (pUserInfo->IsHost()) {
			printf("Is Host: true\n");
			}
			else {
				printf("Is Host: false\n");
			}

		}

	}
}

```

![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/4/2/42f8786572b6327b9eacaf81f037b1d9e681f1da.png)

---

<div class="post-metadata">

**Author:** ![oren.nahum1](https://avatars.discourse-cdn.com/v4/letter/o/ad7895/32.png) [@oren.nahum1](https://devforum.zoom.us/u/oren.nahum1)\
**Post date:** [September 26, 2023, 8:33am UTC](https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547/3 "2023-09-26T08:33:49Z")

</div>

Hi @chunsiong.zoom , Thanks for your reply!

I have updated the SDK in our solution, currently using latest: 5.16.0.22251.

I have done the same as you - tried with an if else clause. However, I am experiencing the same results. Always false. I will link code and logs below.

Question -  
Have you run those lines of code inside the `onUserJoin` callback?  
Because everywhere else (any other callback afterwards) it works, I have tested this in other callbacks.  
But it is crucial that I can determine who the host is inside the `onUserJoin` specifically.

Code:

```auto
void CMeetingServiceMgr::onUserJoin(IList<unsigned int >* lstUserID, const wchar_t* strUserList)
{
	::log("INFO: CMeetingServiceMgr::onUserJoin START ");

	if (lstUserID && m_pMeetingService)
	{
		int count = lstUserID->GetCount();
		for (int i = 0; i < count; i++)
		{
			int userId = lstUserID->GetItem(i);
			IUserInfo* pUserInfo = this->GetUserByUserID(userId);
			if (pUserInfo)
			{
				using convert_type = codecvt_utf8<wchar_t>;
				wstring_convert<convert_type, wchar_t> converter;
				auto uname = (wstring)pUserInfo->GetUserNameW();
				string str_uname = converter.to_bytes(uname);
				::log("user info:");
				::log(to_string(userId) + " " + str_uname);
				::log("isHost:");
				::log(std::to_string(pUserInfo->IsHost()));
				if (pUserInfo->IsHost()) {
					::log("isHost: TRUE");
				}
				else {
					::log("isHost: FALSE");
				}
			}
		}
	}

	auto pUsers = m_pUserCtrl->GetParticipantsList();
	if (!pUsers)
	{
		::log("Could not GetParticipantsList. Cannot get user id.");
	}

    // Trying with iterating.
	for (auto i = 0; i < pUsers->GetCount(); i++)
	{
		auto user_id = pUsers->GetItem(i);
		auto pUser = this->GetUserByUserID(user_id);

		string current_user_name = WCharToString(pUser->GetUserNameW());
		::log("pUser->GetUserNameW():");
		::log(current_user_name);
		::log("isHost:");
		::log(std::to_string(pUser->IsHost()));
		if (pUser->IsHost()) {
			::log("isHost: TRUE");
		}
		else {
			::log("isHost: FALSE");
		}
	}
}

```

Logs:

```auto
2023-09-26 08:25:05.366 3612909816Chorus911183868F47829455DAED58668858A7184 INFO: CMeetingServiceMgr::onUserJoin START 
2023-09-26 08:25:05.367 3612909816Chorus911183868F47829455DAED58668858A7184 user info:
2023-09-26 08:25:05.367 3612909816Chorus911183868F47829455DAED58668858A7184 16779264 Chorus911
2023-09-26 08:25:05.368 3612909816Chorus911183868F47829455DAED58668858A7184 isHost:
2023-09-26 08:25:05.368 3612909816Chorus911183868F47829455DAED58668858A7184 0
2023-09-26 08:25:05.369 3612909816Chorus911183868F47829455DAED58668858A7184 isHost: FALSE
2023-09-26 08:25:05.369 3612909816Chorus911183868F47829455DAED58668858A7184 pUser->GetUserNameW():
2023-09-26 08:25:05.370 3612909816Chorus911183868F47829455DAED58668858A7184 Oren Nahum
2023-09-26 08:25:05.371 3612909816Chorus911183868F47829455DAED58668858A7184 isHost:
2023-09-26 08:25:05.371 3612909816Chorus911183868F47829455DAED58668858A7184 0
2023-09-26 08:25:05.372 3612909816Chorus911183868F47829455DAED58668858A7184 isHost: FALSE
2023-09-26 08:25:05.372 3612909816Chorus911183868F47829455DAED58668858A7184 pUser->GetUserNameW():
2023-09-26 08:25:05.372 3612909816Chorus911183868F47829455DAED58668858A7184 Chorus911
2023-09-26 08:25:05.372 3612909816Chorus911183868F47829455DAED58668858A7184 isHost:
2023-09-26 08:25:05.373 3612909816Chorus911183868F47829455DAED58668858A7184 0
2023-09-26 08:25:05.374 3612909816Chorus911183868F47829455DAED58668858A7184 isHost: FALSE

```

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [September 26, 2023, 1:25pm UTC](https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547/4 "2023-09-26T13:25:58Z")

</div>

@oren.nahum1 ,

as requested. This is slightly harder to test as

1. the host needs to leave and rejoin (without assigning the host to someone else when leaving) or
2. the SDK needs to join before the host

![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/b/5/b5823b5a970099f0987afe5d790a27c8a427f351.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/e/1/e1d1fd072222ced8db4a917042e047d87bc1232b.jpeg)

---

<div class="post-metadata">

**Author:** ![oren.nahum1](https://avatars.discourse-cdn.com/v4/letter/o/ad7895/32.png) [@oren.nahum1](https://devforum.zoom.us/u/oren.nahum1)\
**Post date:** [September 27, 2023, 2:43pm UTC](https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547/5 "2023-09-27T14:43:33Z")

</div>

Thanks @chunsiong.zoom , that worked.

---

<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:** [October 28, 2023, 12:43am UTC](https://devforum.zoom.us/t/inside-onuserjoin-every-user-returns-false-when-calling-ishost-even-for-the-host-itself/95547/6 "2023-10-28T00:43:59Z")

</div>

Closed on October 28, 2023, 12:43am UTC

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