Forum versions: All
Description: I found this as a request here: https://help.forumotion.com/t77525-custom-banned-screen
Based on that, this code will redirect user to a custom made banned page from witch he won't be able to reach any part of your forum again until ban is over. Currently, banned users can browse forum, with this script they are completely stripped from that privilage so that they can't go to register page and make a new account and cause you addition trouble.
Downside: It is JS based so, if the user disables javascript in his browser, he can easily override it or if he clears cookies, he can do the same. However, despite deleting cookies, if he tries to login again, same thing will happen as mentioned above.
Preview:
This text will be centered on the banned page. You can customize this page as you wish, however, I just made the very simple example of it.
Let's role.
1. Go to AP - Modules - HTML & JAVASCRIPT - HTML pages management
2. Click here:
3. Add this code in Page content:
For the first part of the settings, do like this:
4. Click on the submit button:
5. Go again to html pages management and see the URL for your banned page:
DO NOT TURN OFF THIS PAGE. We will need it later.
6. AP - Modules - HTML & JAVASCRIPT - Javascript codes management
Click here:
Title of script: Unique banned page - All versions
Placement: In all the pages
Javascript code:
Now, be very careful to change two things in this code. Both of them are on the top. First one is this variable:
Inside these quotes you will but your normal forum URL. Something like: "https://example.forumotion.me/"
Now, second variable:
You must check on HTML pages URL I told you not to turn off and see what comes after "https://example.forumotion.me/". Copy that and place it here:
You can test this with your test account. Ban it and logout from main account. Then try to login and you won't be able to go to forum again. In order to fix this you will either delete cookies or press F12, go to console, type this "localStorage.clear();" and press enter.
Hope you like it!
Description: I found this as a request here: https://help.forumotion.com/t77525-custom-banned-screen
Based on that, this code will redirect user to a custom made banned page from witch he won't be able to reach any part of your forum again until ban is over. Currently, banned users can browse forum, with this script they are completely stripped from that privilage so that they can't go to register page and make a new account and cause you addition trouble.
Downside: It is JS based so, if the user disables javascript in his browser, he can easily override it or if he clears cookies, he can do the same. However, despite deleting cookies, if he tries to login again, same thing will happen as mentioned above.
Preview:
This text will be centered on the banned page. You can customize this page as you wish, however, I just made the very simple example of it.
Let's role.
1. Go to AP - Modules - HTML & JAVASCRIPT - HTML pages management
2. Click here:
3. Add this code in Page content:
- Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Banned User</title>
</head>
<body>
<div id="banned-message"></div>
<script>
var endDate = localStorage.getItem('bannedUntil');
// Display the banned message with the ban end date
const messageDiv = document.getElementById('banned-message');
messageDiv.textContent = `You are banned until ${endDate}`;
messageDiv.style.position = 'absolute';
messageDiv.style.top = '50%';
messageDiv.style.left = '50%';
messageDiv.style.transform = 'translate(-50%, -50%)';
messageDiv.style.fontSize = '24px';
messageDiv.style.fontWeight = 'bold';
messageDiv.style.textAlign = 'center';
</script>
</body>
</html>
For the first part of the settings, do like this:
4. Click on the submit button:
5. Go again to html pages management and see the URL for your banned page:
DO NOT TURN OFF THIS PAGE. We will need it later.
6. AP - Modules - HTML & JAVASCRIPT - Javascript codes management
Click here:
Title of script: Unique banned page - All versions
Placement: In all the pages
Javascript code:
- Code:
$(document).ready(function() {
// Define the forum URL and banned page URL as variables
var forumURL = "";
var bannedPage = forumURL + "h3-banned-user";
var url = window.location.href;
// Function to check if the URL is part of the forum
function isForumPage(url) {
return url.includes(forumURL);
}
// Function to check if the user is banned
function isUserBanned() {
var bannedUntil = localStorage.getItem('bannedUntil');
if (bannedUntil) {
// Parse the banned until date string into year, month, and day components
var dateComponents = bannedUntil.split("/");
var year = parseInt(dateComponents[2]);
var month = parseInt(dateComponents[1]) - 1; // Months are zero-based
var day = parseInt(dateComponents[0]);
// Create a Date object with the parsed components
var banEndDate = new Date(year, month, day);
var currentDate = new Date();
// If the ban end date has not passed, return true
if (currentDate.getTime() < banEndDate.getTime()) {
return true;
} else {
// If the ban end date has passed, clear localStorage
localStorage.removeItem('bannedUntil');
}
}
return false;
}
// Check if the user is trying to access any part of the forum
if (isForumPage(url)) {
// Check if the user is banned
if (isUserBanned()) {
// Redirect to the banned user page
window.location.href = bannedPage;
}
}
// Check if the current URL is the login page
if (url.includes("/login")) {
// Get the elements with the class 'block-content', 'msg', 'gen', or <p> elements
var elements = document.querySelectorAll('.block-content, .msg, .gen, p');
var bannedMessage = null;
// Loop through the elements to find the banned message
elements.forEach(function(element) {
if (element.textContent.includes("You have been banned from this forum.")) {
bannedMessage = element.textContent;
// Extract the date using regex
var bannedUntilMatch = element.innerHTML.match(/Until (\d{2}\/\d{2}\/\d{4})/);
if (bannedUntilMatch) {
var bannedUntil = bannedUntilMatch[1];
// Store the banned until date in localStorage
localStorage.setItem('bannedUntil', bannedUntil);
// Redirect to the banned user page with the ban end date as a URL parameter
window.location.href = bannedPage + "?endDate=" + bannedUntil;
return;
}
}
});
}
});
Now, be very careful to change two things in this code. Both of them are on the top. First one is this variable:
|
Now, second variable:
|
|
You can test this with your test account. Ban it and logout from main account. Then try to login and you won't be able to go to forum again. In order to fix this you will either delete cookies or press F12, go to console, type this "localStorage.clear();" and press enter.
Hope you like it!