MyBB Community Forums

Full Version: Restricting Guest Access
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
myBB is completely new for me, but I spent some time to get familiar with it. Had looked at phpBB before, but currently believe that myBB would be the better choice for me.

I'm running all my tests on a VM which is not reachable from outside. 
MyBB version: 1.8.22
PHP version: 7.3.18
DB: MySQLi 8.0.20

I'm struggeling with the Guest Access to the various content. While it is not a problem to control which forums a guest can see and whether they can read threads or not, I couldn't find a way to hide embedded pictures or videos from guests. Yes, they can not access attachments, but see the embedded pictures. (Registered user can embed pictures as big "thumbnails" in my case).
I would also like to hide links.

I tried several plugins (Hide from users and/or Guests, Custom User Permissions, My Permissions, Registered Links, Custom Restriction) but none of them did the trick, at leat not for pictures. (and some get SQL errors).

Secondly I would like to disable the Portal for guests, but not for registered users.

Any help is appreciated.
From what I can deduce, you probably need to adjust the guest permissions in user and groups -> groups to stop them accessing attachments.
If it's for embedded pictures, you may need a plugin for that. However, I'm not sure about this and there probably is another way
For hiding links from guests, I believe you need to download a plugin for that. I think looking around for a bit will help you find that.


To disable the portal.php from certain groups (guests in your case), what i've done (when I was faced with a similar situation) is edit the portal.php file with the following:
$allowed = array('X1'); // 

if(!in_array($mybb->user['usergroup'], $allowed))
{
	error('X2', 'Main Board');
}

Where X1 = the Group IDs that are allowed to view the page
          X2 = The Error message you want displayed.

Hopefully this is what you are looking for in this respect of disabling portal.php from guests
Used to be a 1.6x plugin - SCD Hide from Groups - that restricted MyCode tags and forums for a list of groups by gid.  You could set custom messages and append text to the hidden content if memory serves.

We used it up until 2013 or so, but haven't found anything quite like it since we upgraded.  Maybe someone else has found a decent substitute.  Much of it can be achieved with core permissions, but not the mycode stuff don't think.

cheers...
Thanks.
Tested the portal stuff and that works fine. Kept it quite simple for now:
// quick and dirty
if($mybb->user['usergroup'] == 1)
{
        error($lang->portal_disabled);
}

I thought I repeat the same trick for the memberlist, but then I found that it is already possible to disable this for the guest.
if($mybb->usergroup['canviewmemberlist'] == 0)
...

And that is also checked in global.php, which is I think the reason that a guest even can't see the icon to click on for the memberlist.
I guess the best solution would be to invent a 'canviewportal' and allow to change this in the group configuration problem

For the other question (hiding images from guests) I went back to the plugin I had tried to use before, "Hide from Guests and Users (3.0)".
This time I used another myBB instance which was coming with an older MySQL version, 5.7.3.
This time I could activate the plugin without SQL error and after configuring the plugin as needed it works as expected. :-)

That SQL error I saw with MySQL 8.0 is easy to fix - and I had tried that before, but for some reason the plugin blocked the images for everyone - and I still don't know what went wrong. Even in a fresh myBB installation where I changed the plugin code before activating the first time, the images where blocked again for every one.
It is working now, so I guess I made something wrong with the plugin configuration, even though I'm quite sure it was the same as in the other installation. But perhaps I was blind .....

For completeness and why I already mentioned it here (even though it is a plugin discussion) this is the problem I saw with activating the plugin.
This is the query that failed:
SELECT COUNT(*) as rows FROM mybb_settinggroups

I guess "rows" is a reserved word in MySQL 8, but not in 5.7.

So I changed hideguestsusers.php as follows:

from:
$query = $db->simple_select("settinggroups", "COUNT(*) as rows");
$rows = $db->fetch_field($query, "rows");

to:
$query = $db->simple_select("settinggroups", "COUNT(*) as nrows");
$rows = $db->fetch_field($query, "nrows");



Cheers
In your case i'd consider excluding all guests (make logging in compulsory).
That is actually not an option. Even unregistered people should see - some - interesting stuff. For other stuff they need to login (Hoping that they will register).
This is how it works in the forum I'm going to administrate (which is unfortunately based on some old software no longer maintained) and that is what the moderator team wants to keep.