Help & Support

Banned Accounts

This guide explain how to ban and unban accounts from a group.

A Group configured with the Ban Member Group Rule allows the Group owner or admins to ban accounts from joining the Group. However, banning an account after it has already joined the Group does not remove it.

More details on how to remove a Group member and ban them contextually will be provided soon.

Ban Accounts

To ban one or mores accounts from joining a Group, follow these steps.

You MUST be authenticated as Builder, Account Manager, or Account Owner and be the Group owner or an admin to perform this action.

1

Ban the Accounts

Use the banGroupAccounts action to ban one or more accounts from joining a given Group.

Ban Accounts
import { evmAddress } from "@lens-protocol/client";import { banGroupAccounts } from "@lens-protocol/client/actions";
const result = await banGroupAccounts(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x4f92…")],});
if (result.isErr()) {  return console.error(result.error);}

2

Handle Result

Then, handle the result using the adapter for the library of your choice:

import { handleOperationWith } from "@lens-protocol/client/viem";
// …
const result = await banGroupAccounts(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x4f92…")],}).andThen(handleOperationWith(walletClient));

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.

That's it—these accounts are now banned from joining the Group.

List Banned Accounts

Use the paginated fetchGroupBannedAccounts action to list all banned accounts for a given Group.

All members of a group
import { evmAddress } from "@lens-protocol/client";import { fetchGroupBannedAccounts } from "@lens-protocol/client/actions";
import { client } from "./client";
const result = await fetchGroupBannedAccounts(client, {  group: evmAddress("0x1234…"),});
if (result.isErr()) {  return console.error(result.error);}
// items: Array<GroupBannedAccount>: [{ account: Account, bannedAt: DateTime, bannedBy: Account, …}, …]const { items, pageInfo } = result.value;

See the Pagination guide for more information on how to handle paginated results.

Unban Accounts

To revert bans and allow accounts to join a Group again, follow these steps.

You MUST be authenticated as Builder, Account Manager, or Account Owner and be the Group owner or an admin to perform this action.

1

Unban the Accounts

Use the unbanGroupAccounts action to unban one or more accounts for a given Group.

Ban Accounts
import { evmAddress } from "@lens-protocol/client";import { unbanGroupAccounts } from "@lens-protocol/client/actions";
const result = await unbanGroupAccounts(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x4f92…")],});
if (result.isErr()) {  return console.error(result.error);}

2

Handle Result

Then, handle the result using the adapter for the library of your choice:

import { handleOperationWith } from "@lens-protocol/client/viem";
// …
const result = await unbanGroupAccounts(sessionClient, {  group: evmAddress("0xe2f…"),  accounts: [evmAddress("0x4f91…"), evmAddress("0x4f92…")],}).andThen(handleOperationWith(walletClient));

See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.

That's it—these accounts are now banned from joining the Group.