MyBB Community Forums

Full Version: Make something only visible for guests
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I make an custom div only visible for guests on my mybb forum?
Is there maybe an option that allows you to make a div visible for only one user group?
I would really appreciate help.

Thanks in advance
Depending on what you want you could honestly just put it in the header_welcomeblock_guest template.
(2022-02-16, 10:40 PM)Taylor M Wrote: [ -> ]Depending on what you want you could honestly just put it in the header_welcomeblock_guest template.

Yeah, I thought of that. The only issue is that if I put it in the header_welcomeblock_guest template, it will show on all pages. I want it to only show on the index page.
<div class="guest-message guest-message-{$mybb->user['usergroup']}">
Content here
</div>

Then add this CSS to your theme:

.guest-message {
    display: none;
}
.guest-message-1 {
    display: block;
}

The HTML would still be viewable to all users if they viewed the page source, but it'll only be visible on the page to guests.

Not an ideal solution, the only other way us to use the PHP conditionals in templates plugin.
(2022-02-17, 05:27 PM)Matt Wrote: [ -> ]
<div class="guest-message guest-message-{$mybb->user['usergroup']}">
Content here
</div>

Then add this CSS to your theme:

.guest-message {
    display: none;
}
.guest-message-1 {
    display: block;
}

The HTML would still be viewable to all users if they viewed the page source, but it'll only be visible on the page to guests.

Not an ideal solution, the only other way us to use the PHP conditionals in templates plugin.

Thank you SO much! You don't understand how much this meant for me.
I really appreciate it!
(2022-02-17, 05:27 PM)Matt Wrote: [ -> ]
<div class="guest-message guest-message-{$mybb->user['usergroup']}">
Content here
</div>

Then add this CSS to your theme:

.guest-message {
    display: none;
}
.guest-message-1 {
    display: block;
}

The HTML would still be viewable to all users if they viewed the page source, but it'll only be visible on the page to guests.

Not an ideal solution, the only other way us to use the PHP conditionals in templates plugin.

Thank you! this worked perfectly.  Cool