Blocked users should have read permissions

darkeye

Active member
Hello,

If a user is banned, they can basically do nothing afterward, including read posts.

What do I have to do so that a banned user can continue reading posts? They shouldn't have write permissions, only read posts, as if they were a guest who isn't allowed to write.

I tried the following:

In the admin area /admin.php?options/groups/discourager/#addBanUserGroup

I selected "guests" for "Add user group when banned."
That didn't work; a banned user still can't read anything.

I then created a new user group called "banned users" and set the following for "User group permissions":

- Can see the page: YES

- Can see the forum: YES

That didn't work either. What did I do wrong?
 
"banned" is its own state in XenForo. The users in question will need to log out to view whatever they can as a Guest. Some people implement their own "bans" by creating groups with limited permissions and placing users into those - you could automate that to a degree with the warnings system.
 
But if you're blocked, you can't even log out. You can't do anything. You're basically dead.

I think it would be fair if you at least had read access.
 
You should be able to logout - Pretty sure there is a logout link under the "you are banned" message (but maybe I have that from an add-on or config option). There are a few threads discussing it here but I think as it stands at present it's "as designed" so you'd have to petition the developers to change the functionality.
 
For me, there's definitely no unsubscribe link, just this:

Oops! We encountered a problem.
You have been banned. Your ban will be lifted on April 24, 2025, at 12:00 AM.

Even clicking on my profile in the menu above has no effect.
 
But if you're blocked, you can't even log out. You can't do anything. You're basically dead.

I think it would be fair if you at least had read access.
That's true, you can't do a thing. Only way is to delete the cookie so you're viewing as a guest. I also think it should allow a user to log out. Dunno about read permissions though as no, don't wanna see their sorry ass ever again.

I have a read only group that I've nicknamed the "straitjacket" for really naughty users who's time is up at my forum. I put them in that so that I can send them a detailed pm shortly and have them read it before I actually bring down that ban hammer, as the full context for the ban must always be clear. After I'm sure they've read it, I then ban them.
 
What do I have to do so that a banned user can continue reading posts?
Don't ban them :)

As you already figured out, banned users intentionally can't do anything - not even log out (to prevent them from registering a new account; for not-taht-savy users this does indeed work to some extend, everbody else will just delete cookies and start over).
This is how banning is designed, it's meant to block them from doing anything.

They shouldn't have write permissions, only read posts, as if they were a guest who isn't allowed to write.
Use warnings and warning actions to add them to usergroups that revoke certain permissions.
 
Hello,

If a user is banned, they can basically do nothing afterward, including read posts.

What do I have to do so that a banned user can continue reading posts? They shouldn't have write permissions, only read posts, as if they were a guest who isn't allowed to write.

I tried the following:

In the admin area /admin.php?options/groups/discourager/#addBanUserGroup

I selected "guests" for "Add user group when banned."
That didn't work; a banned user still can't read anything.

I then created a new user group called "banned users" and set the following for "User group permissions":

- Can see the page: YES

- Can see the forum: YES

That didn't work either. What did I do wrong?
I think you can. If you set banned users to a new usergroup "Banned" and set the permissions correctly.

admin.php?options/groups/discourager/

Screen Shot 2025-04-17 at 5.36.51 PM.webp

Then set permissions admin.php?permissions/user-groups/banned.5/

Screen Shot 2025-04-17 at 5.38.10 PM.webp
 
Have you moved the banned users to the banned group?
Banned users can't do anything!

This is hardcoded in XF\Pub\Controller\AbstractController

PHP:
public function assertNotBanned()
{
    if (\XF::visitor()->is_banned)
    {
        throw $this->exception(
            $this->plugin('XF:Error')->actionBanned()
        );
    }
}

So unless a controller specifically overrides this method (only the Error, Help and ServiceWorker controllers do that) all banned users ever will get is an error message stating that they have been banned, it doesn't matter which permissions they have.
 
Yeah, there's a flag in the user table for if they're banned and that's checked on every page and throws a generic error (as Kirby just pointed out as I was typing lol).

So to let them still do something, they'd need to not be banned and just be put in a group with restricted permissions. It's just not designed to allow them to do anything when banned.
 
Thanks, it's working halfway now. The user can't be blocked; I have to manually add them as an admin to the "Blocked Users" group.

But what good does that do me if a moderator wants to block a user for 7 days and provides a reason? The user can't see the reason for the ban.

Then I have to manually unblock the blocked user after 7 days. That's not the best solution either.
 

 
As mentioned upthread use the Warnings system (/admin.php?warnings/)

To do a "ban" as a warning - create the warning, points don't really matter. Set a sensible expiry if your "bans" are a typical length or "never" if they are permanent. Leave the editable box ticked if you want your mods to be able to set the "ban" duration. Then tick the box for your "ban group in the extra user groups section, tweak the message as required. Save. Now your mods can issue this warning and set the expiry for however long the ban should last for.
 
Back
Top Bottom