Post by Chris on Oct 19, 2023 0:04:15 GMT -8
Hi,
Is there any way to change the default text message that my forum displays when a user (guest) does not have permission to access the page or the post?
"Oops, there was an error! You do not have permission to access this thread."
Is there any way to change the default text message that my forum displays when a user (guest) does not have permission to access the page or the post?
"Oops, there was an error! You do not have permission to access this thread."
Change Oops Message.pbp
(Downloading and Importing Plugins [GUIDE])
The following code should probably be a plugin to allow for easy editing but here it is in its naked form:
<script>
/* Change "Oops" Message (Global Header) */
(function(opts){
const page = pb.data('page'), route=pb.data('route'), user = pb.data('user'), oops = page && Object.keys(page).length==0;
if(oops){
let $style = $('<style />').appendTo('head');
$style[0].sheet.insertRule('.container.error{display:none}', 0);
$(function(){
let $err = $('.container.error');
let user_msg = user.username && opts[user.username] ? opts[user.username]: (opts[user.id]?opts[user.id]:opts['everyone'])
if($err.length && user_msg && route.name in user_msg){
user_msg[route.name].title && $err.find('.title-bar').html('<h2>' + user_msg[route.name].title +'</h2>');
user_msg[route.name].content && $err.find('.content').html( user_msg[route.name].content );
$err.show();
}
})
}
})({
everyone:{
thread: {title: "Thread Viewing Error", content: "It appears you broke the forum again"},
board: {title: "Board Viewing Error", content: "You have really done it this time!"}
},
neo: {
thread: {title: "Thread Matrix Error", content: "Why do you persist Mr. Anderson?!"},
board: {title: "Board Matrix Error", content: "Wake up Neo, you cannot see beyond this board choice you just made"}
},
0: {
thread: {title: "Thread Viewing Error", content: 'Please <a href="/blah">login</a> or <a href="/blah">register</a> to view this thread'},
board: {title: "Board Viewing Error", content: 'Please <a href="/blah">login</a> or <a href="/blah">register</a> to view this board'}
}
});
</script>
You can define an error message for individuals via username or userID and for "everyone" else not covered by a username or userID entry. In the code above there are three entries: "everyone", "neo", 0
The user with the login name "neo" will get his own personalized message and Guests (userID is 0) will get their own while everyone else will get the "everyone" branch. If you want it left untouched for everyone else then just leave out the everyone entry. Obviously add more users if you want to personalize for others or just leave the 0 entry to affect only guests.
Each entry is subdivided to match the route (thread, board, etc., so you can have unique messages for each situation) and those in turn are subdivided to supply replacement (optional) title and/or (optional) content