MyBB Community Forums

Full Version: Redirect Banned Users From Homepage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Assuming:
1. Your homepage is index.php
2. Your banned usergroup id is 7 (default).

Now open your index page template:
ACP > Templates & Styles > Templates > {your_theme} Templates > Index Page Templates > Index

Find the code:
<body>

Replace with:
<body onload="bannedredirect()">

Now add just above it:
<script type="text/javascript">
function bannedredirect()
{
    if({$mybb->user['usergroup']} == 7)
    {
        window.location="{$mybb->settings['bburl']}/misc.php?page=banned";
    }
}
</script>

Now design your Banned Message Page using "Page Manager" with URI Parameter banned

You can use the trick to redirect other usergroups also to other pages as you like.
Well they'd have to be logged in for this to work. They could still log out and just view the main page.

Also, this won't work if they disable Javascript. Or if they just block this particular script.

However a simple plugin could remedy the second issue, and somewhat remedy the first.

You could just use a plugin to redirect (with PHP) anyone who is logged in and is in the usergroup, OR who has an IP matching an IP of a banned user.

Of course, the last one isn't exactly ALWAYS going to work, because of dynamic IPs. But it's a solution for the case of a logged out user.
This only works if using js as member mentioned above.

Best is to use header(location: somepage.php) .