Block List

Documentation → Block List

Ensuring your user’s preferences about which users are blocked from contacting them is a key piece of providing a safe and secure community for your users to communicate in. When a user is blocked within the Userplane experience, the block is honored immediately. However the persistence of that block is entirely dependent on how you integrate the block list with Userplane. Further the opposite is true that if someone blocks a user on your site it will be necessary to notify Userplane of the change so that we can stay in sync with the users wishes. In implementing the below points you will be accounting for the different ways in which Userplane and your website may need to communicate to provide the best possible experience.

Providing the Existing Block List

Ideally at the beginning of every session you should provide the current state of the block list as you know it. We will honor this list immediately as accurate and use it until the user makes and adjustment or we are notified otherwise.

In order to provide an existing blocklist, you will need to use the Javascript API available in the Userplane SDK to programmatically set blocked users in the local user’s block list. Below is an example:

ArgumentDescriptionRequired
blockListArray An array of blocked users
// example of javascript array
[ "user01","user02","user03" ]
Yes

Example

Adding the following code after your embed code (the call to up.init) will add a callback and execute the up.api.setBlockList Javascript API method to set the blocked state for the designated users.

// onReady is a call back handler which gets executed when the SDK has fully loaded.
onReady = function() {
    // Here we create a blockedUser array with all the users you wish to block.
    var blockedUsers = [ "user01","user02","user03" ];
    //Here we call the Javascript API to set the blocked status for the local user.
    up.api.setBlockList( blockedUsers );
}
// Add the callback to call our onReady method above once the SDK is ready.
up.event.addCallback( up.api.events.READY, onReady );
Confused about callbacks?

Block a user via Javascript

To block a user programmatically you can place a call to the following Javascript API method with the userID from your site.

var userID = "user04";
up.api.buddyList.blockUser( userID );

Unblock a user via Javascript

To unblock a user programmatically you can place a call to the following Javascript API method with the userID from your site.

var userID = "user05";
up.api.buddyList.unBlockUser( userID );