Jump to the post that solved this thread.
Not Solved [How To?] detect guest?
#1
Not Solved
How can i detect guest in header template?
What variables can I use? Is there any document related to this?
Reply
#2
Not Solved
You can rely on the template "header_template_welcome_guest".
This template is displayed for guests (visitors not logged in).

What do you want to achieve exactly?

[ExiTuS]
New Forum / MyBB 1.8.26 + innovative full-responsive Theme
Live-Escape-Game-Forum
Reply
#3
Not Solved
If you wanted to display something only to guests, you can be clever with CSS:

<div class="guest-notice guest-notice-uid-{$mybb->user['uid']}">
...
</div>

.guest-notice {
    display: none;
}

.guest-notice-uid-0 {
    display: block;
}

$mybb->user['uid'] will be 0 for guests so the CSS class would be guest-notice-uid-0 and would then use the CSS to show the div again.

This is assuming this is the sort of thing you wanted to do.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#4
Not Solved
(2021-02-22, 10:46 AM)Matt Wrote: If you wanted to display something only to guests, you can be clever with CSS:

<div class="guest-notice guest-notice-uid-{$mybb->user['uid']}">
...
</div>

.guest-notice {
    display: none;
}

.guest-notice-uid-0 {
    display: block;
}

$mybb->user['uid'] will be 0 for guests so the CSS class would be guest-notice-uid-0 and would then use the CSS to show the div again.

This is assuming this is the sort of thing you wanted to do.

Thanks for reply, so, can i do that?
if ({$mybb->user['uid']}==0){
//guest javascript codes
}else{
//members javascript codes
}
Reply
#5
Not Solved
You can't have conditions in templates without an additional plugin (this is the one people usually use I think http://mybbhacks.zingaburga.com/showthread.php?tid=464).
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#6
Not Solved
As I said before,
put the code for guests into template "header_template_welcome_guest",
for members into "header_template_welcome_member"

[ExiTuS]
New Forum / MyBB 1.8.26 + innovative full-responsive Theme
Live-Escape-Game-Forum
Reply
#7
Not Solved
(2021-02-22, 03:05 PM)[ExiTuS] Wrote: As I said before,
put the code for guests into template "header_template_welcome_guest",
for members into "header_template_welcome_member"

[ExiTuS]

Oh yes, this would work Smile
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#8
Not Solved
(2021-02-22, 10:46 AM)Matt Wrote: If you wanted to display something only to guests, you can be clever with CSS:

<div class="guest-notice guest-notice-uid-{$mybb->user['uid']}">
...
</div>

.guest-notice {
    display: none;
}

.guest-notice-uid-0 {
    display: block;
}

$mybb->user['uid'] will be 0 for guests so the CSS class would be guest-notice-uid-0 and would then use the CSS to show the div again.

This is assuming this is the sort of thing you wanted to do.

Hi Matt! 

I want to do something very similar with this plugin
https://community.mybb.com/mods.php?action=view&pid=462

but to be able to display the message to the every group not just moderator and regardless if they able to post or not

https://community.mybb.com/mods.php?acti...w&pid=1344

Looks I have to change only this

if (is_moderator($fid, "canpostclosedthreads") && $thread['closed'])
        eval("\$newreply = \"".$display.$templates->get("showthread_newreply")."\";");


but I do not know how to do it

Can you please help with this?

Thanks
My forum powered by MyBB https://alhimika.net/forum/
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)