miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Hide and disable certain menu items for guests

 
Author Debbie
Partaker
#1 | Posted: 18 Feb 2014 14:11 
I would like to set up a strictly private forum, available only to pre-approved members of an organization. Is there a way to remove and disable the links for Register, Search, Statistics, and Manual, so that anyone who is not a member of the group cannot register or see user profiles? I would also like to put a message on the index page informing anyone who happens to land there that it is a private forum, but I am not sure which file(s) to edit to accomplish this. Thanks.

Author kuopassa
Partaker
#2 | Posted: 18 Feb 2014 15:45 
Configuration file setup_options.php has settings that allow the whole forum being password protected from outside world. It can be achieved by placing inside setup_options.php these two:

$protectWholeForum = 1;
$protectWholeForumPwd = 'passwordgoeshere';

If you inform your forum's users that password, they can open the forum.

Login form is inside templates folder and is named protect_forums.html, which can of course also include other information, like a message that says this forum is for pre-approved members etc.

Author Debbie
Partaker
#3 | Posted: 18 Feb 2014 17:00 
That wasn't really what I had in mind, because the users will need two passwords, one for the forum, and a separate one for their individual accounts. I don't want to be kept busy emailing the password out to people who lose it. :-) At least it works until I can hopefully figure out a better solution. Thanks.

Author Debbie
Partaker
#4 | Posted: 18 Feb 2014 23:07 
I figured this out by copying and pasting from a couple of posts on this forum.
In case anyone else wants to do something similar, I put the following lines into my bb_plugins.php file:

-----------------------------------------------------

if(($user_id==0) and ($action=='register' or $action=='registernew')){
$enableNewRegistrations=FALSE;
echo load_header();
echo ParseTpl(makeUp('guest_denied'));
$endtime=get_microtime();
$totaltime=sprintf ("%01.3f", ($endtime-$starttime));
if(isset($includeFooter) and $includeFooter!='') include($includeFooter); else echo ParseTpl(makeUp('main_footer'));
exit;
}

if($user_id==0 and $action=='search'){
echo load_header();
echo ParseTpl(makeUp('guest_denied'));
$endtime=get_microtime();
$totaltime=sprintf ("%01.3f", ($endtime-$starttime));
if(isset($includeFooter) and $includeFooter!='') include($includeFooter); else echo ParseTpl(makeUp('main_footer'));
exit;
}

if($user_id==0 and $action=='stats'){
echo load_header();
echo ParseTpl(makeUp('guest_denied'));
$endtime=get_microtime();
$totaltime=sprintf ("%01.3f", ($endtime-$starttime));
if(isset($includeFooter) and $includeFooter!='') include($includeFooter); else echo ParseTpl(makeUp('main_footer'));
exit;
}

if($user_id==0 and $action=='manual'){
echo load_header();
echo ParseTpl(makeUp('guest_denied'));
$endtime=get_microtime();
$totaltime=sprintf ("%01.3f", ($endtime-$starttime));
if(isset($includeFooter) and $includeFooter!='') include($includeFooter); else echo ParseTpl(makeUp('main_footer'));
exit;
}

-----------------------------------------------------

Then I made a page called guest_denied.html with a message saying that it was a private forum, and saved it in my templates directory. Now an unregistered user will still see the menu links, but will only get the error message when they click on one.

Author Paul
Lead Developer 
#5 | Posted: 19 Feb 2014 22:28 
You can compress this into much smaller code:

if($user_id==0 and ($action=='stats' or $action=='manual' or $action=='search' or $action=='register' or $action=='registernew')){
echo load_header();
echo ParseTpl(makeUp('guest_denied'));
$endtime=get_microtime();
$totaltime=sprintf ("%01.3f", ($endtime-$starttime));
if(isset($includeFooter) and $includeFooter!='') include($includeFooter); else echo ParseTpl(makeUp('main_footer'));
exit;
}
Also, remove all the proper {$l_menu[...]} elements from templates/main_header.html i.e.

$l_menu[1] for 'Search'
$l_menu[2] for 'Register'
$l_menu[3] for 'Stats'
$l_menu[4] for 'Manual'

Debbie:
Then I made a page called guest_denied.html with a message saying that it was a private forum, and saved it in my templates directory. Now an unregistered user will still see the menu links, but will only get the error message when they click on one.
Looks like a valid approach, specially if it works for you that way.
Good luck!

Author Debbie
Partaker
#6 | Posted: 19 Feb 2014 23:08 
Thanks. I will try your version. I thought there must be a better, shorter way, but since I don't know too much about php and it worked as is, I didn't want to risk breaking something with a typo. I will keep the menu elements though, because I do want them to be available to anyone who is registered and logged in, with the possible exception of "Register", since they are already registered.

Author Paul
Lead Developer 
#7 | Posted: 19 Feb 2014 23:54 
For disabling Registration option, you did it right before - but must apply it in setup_options.php for all users, not just guests.

I.e. just set

$enableNewRegistrations=FALSE;
in setup_options.php.

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Hide and disable certain menu items for guests
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Try the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑