DELETE UNAUTHORIZED Participant using Web SDK

when user logged in to the meeting via on Web SDK. i want to check whether user is AUTHORIZED or NOT.

So i added this code. Here is my question

When user is NON-AUTHORIZED person . then automatically he or she should be delete by the system or Blacklist them , how can i accomplish this task using WEB SDK ?

  ZoomMtg.inMeetingServiceListener('onUserJoin', function (data) {

            console.log("ON USER JOIN");
            console.log('inMeetingServiceListener onUserJoin', data);

            var loggedUserId = data.userId;
            var loggedUserName = data.userName;

            $.ajax({
                type: "POST",
                url: "{{url('meeting/web/checkAuthorizedUser')}}",
                data: {
                    "loggedUserId": loggedUserId,
                    "loggedUserName": loggedUserName,
                    '_token': '{{csrf_token()}}',

                },
                dataType: 'json',

                success: function (data) {
                    alert(data);
                },

                error: function (data) {
                    console.log(data);
                }


            });
        });
1 Like

Hi @digix.sameera,

You can use the expel() method to remove a particular user from the meeting. Note that you must have kick privileges (Be the host or co-host) in order to do this.

ZoomMtg.expel({
    userId: 123456 //You can get the ID of the user from the onUserJoin event data.
});

Thanks,
Alex

1 Like

thanks @alexmayo

I run this code , then i got this console error message.

Please note
I started this meeting as a HOST . then i reload page. and execute this code.

    {method: "expel", status: false, errorCode: 1, errorMessage: "Current user is neither host nor cohost", result: null}

errorCode: 1
errorMessage: “Current user is neither host nor cohost”
method: “expel”
result: null
status: false

1 Like

Can you please post your ZoomMtg.join() code?

You also need to ensure that the role parameter is set to 1 when creating your signature.

Thanks,
Alex

 function websdkready() {
    var testTool = window.testTool;
    // get meeting args from url
    var tmpArgs = testTool.parseQuery();
    console.log(tmpArgs)




    var meetingConfig = {
        apiKey: tmpArgs.apiKey,
        meetingNumber: tmpArgs.zoomMeetingId,
        userName: tmpArgs.userName,
        passWord: tmpArgs.meetingPassword,
        leaveUrl: "/index.html",
        role: parseInt(tmpArgs.meetingRole),
        userEmail: tmpArgs.userEmail,
        lang: tmpArgs.meetingLang,
        signature: tmpArgs.signature || "",
        china: tmpArgs.china === "1",
    };

    // a tool use debug mobile device
    if (testTool.isMobileDevice()) {
        vConsole = new VConsole();
    }

    if (meetingConfig.china)
        ZoomMtg.setZoomJSLib("https://jssdk.zoomus.cn/1.9.1/lib", "/av"); // china cdn option
        ZoomMtg.preLoadWasm();
        ZoomMtg.prepareJssdk();

    function beginJoin(signature) {
        ZoomMtg.init({
            leaveUrl: meetingConfig.leaveUrl,
            webEndpoint: meetingConfig.webEndpoint,
            disableInvite: true,
            disableCallOut: true,
            debug: true,
            isSupportAV: true,
            isSupportChat: false,
            meetingInfo: [],

            success: function () {
                ZoomMtg.i18n.load(meetingConfig.lang);
                ZoomMtg.i18n.reload(meetingConfig.lang);

                console.log(meetingConfig);

                ZoomMtg.join({
                    meetingNumber: meetingConfig.meetingNumber,
                    userName: meetingConfig.userName,
                    userEmail: meetingConfig.userEmail,
                    signature: signature,
                    apiKey: meetingConfig.apiKey,
                    passWord: meetingConfig.passWord,

                    success: function (res) {
                        console.log("join meeting success");
                        console.log(res);
                    },
                    error: function (res) {
                        console.log(res);
                    },
                });
            },
            error: function (res) {
                console.log(res);
            },
        });

        ZoomMtg.inMeetingServiceListener('onUserJoin', function (data) {
            console.log("ON USER JOIN");
            console.log('inMeetingServiceListener onUserJoin', data);
            ZoomMtg.expel({
                userId: 16779264
            });
        });

    }
    beginJoin(meetingConfig.signature);

};
1 Like

@digix.sameera
I notice that you are hard coding the value 16779264 however you should instead get this userID from the event data variable, and expel them if they are not allowed to be in the meeting.

1 Like

No @alexmayo

I cannot find out “role” parameter accept for ZoomMtg.join({})

Please refer zoom join section
https://marketplace.zoom.us/docs/sdk/native-sdks/web/reference

1 Like

My apologies! The role parameter should be configured when generating your signature.

1 Like

Thanks for jumping in and helping @alexmayo!

Best,
Will

1 Like

No problem, Thanks @alexmayo

Here is the solution

   ZoomMtg.init({
            leaveUrl: meetingConfig.leaveUrl,
            webEndpoint: meetingConfig.webEndpoint,
            disableInvite: true,
            disableCallOut: true,
            debug: true,
            isSupportAV: true,
            isSupportChat: false,
            meetingInfo: [],

            success: function () {
                ZoomMtg.i18n.load(meetingConfig.lang);
                ZoomMtg.i18n.reload(meetingConfig.lang);

                console.log(meetingConfig);

                ZoomMtg.join({
                    meetingNumber: xxxxxxx
                    userName: xxxxxx
                    userEmail: xxxxxx
                    signature: xxxxxx,
                    apiKey: xxxxxx
                    passWord: x,xxxxxxx

                    success: function (res) {
                        console.log("join meeting success");
                        console.log(res);
                    },
                    error: function (res) {
                        console.log(res);
                    },
                });
            },
            error: function (res) {
                console.log(res);
            },
        });


  ZoomMtg.inMeetingServiceListener('onUserJoin', function (data) {
            console.log("ON USER JOIN");
            console.log('inMeetingServiceListener onUserJoin', data);

     if(condition){

            var userId = data.userId;
            ZoomMtg.expel({
                userId: userId
            });
        });
 }
1 Like

Glad you were able to find a solution! :slight_smile:

2 Likes