realtime_check_permission( )


Checks permissions for a subscriber on a channel or channel resource.

The realtime_check_permission hook is triggered when a site visitor subscribes to a channel to check what permissions the subscriber will have.

The realtime_check_permission() function is not a function that you call from your code. You define the function in a file named realtime-permissions.js in your site's Backend section.

Important:

  • If this function isn't defined, all subscribers will receive the default permissions: {"read": true}.
  • In Wix Studio, you don't need to define this function, but you must create a backend file named realtime-permissions.js. Without this file, subscriptions will fail.

Implement permissions logic for channels and subscribers by either:

  • Including all permissions logic in the body of this function.
  • Use the PermissionsRouter to add permissions logic per channel. Then call check() in the body of this function and return the permissions object it returns.

Note: When previewing your site, permissions for read are always granted.

Method Declaration
Copy
Method Parameters
channelChannelRequired

The channel, and optionally the resource, to check permissions for.


subscriberSubscriberRequired

The subscriber to check permissions for.

Returns
Return Type:Promise<ChannelPermissions> | ChannelPermissions
Was this helpful?
Yes
No