Hi - I have installed Template conditional, and also have Ajax Shoutbox working
I want to make this shoutbox invisable to banned users and guests and those awaiting activation
Editing the Index template (where shoutbox is invoked)
I changed this
{$shoutbox}
to this
<if !in_array($GLOBALS['mybb']->user['usergroup'], array(2,3,4,6)) then>
{$shoutbox}
</if>
but it does not work - I get no error, but with that change, shoutbox is now invisible to ALL user groups
I know nothing about php scripting, and the above is my just my best guess based on other forum postings on similar issues.
I obviously have something wrong though, and would be very grateful for corrected version!
Cheers
Are you sure you got the group IDs correct?
Also, are you trying to hide from certain users or make visible to certain users? Your code above hides the content from the listed group IDs.
Hi - I am basing my group IDs on the order in which they are listed by default in AdminCP/Users and Groups/Groups.
So I am assuming "1" would be Guests, "2" would be Registered users , "3" would be Super Moderators .. etc
If wrong, are the correct IDs listed anywhere? I have not been able to find a complete list explicitly relating group number to group name anywhere.
I also did not realize I was hiding content this way ! What should the script be to instead reveal {$shoutbox} to only groups 2,3,4 & 6 ?
Cheers
Your method of getting IDs is probably accurate (for now), but I wouldn't count on it. Just edit a group and look for a gid= in the URL - this will be the real group ID.
The exclamation mark (!) means 'not', so try removing that.
(07-31-2012 11:38 PM)ZiNgA BuRgA Wrote: [ -> ]Your method of getting IDs is probably accurate (for now), but I wouldn't count on it. Just edit a group and look for a gid= in the URL - this will be the real group ID.
The exclamation mark (!) means 'not', so try removing that.
Hi - I confirmed the gid's are indeed as predicted, and deleted the exclamation mark - but no change in performance:
<if in_array($GLOBALS['mybb']->user['usergroup'], array(2,3,4,6)) then>
{$shoutbox}
</if>
still never invokes {$shoutbox}, though shoutbox does appear normally if I simply add {$shoutbox} above or below this conditional statement.
Is there something wrong with the way this is looking up the usergroup array?
As a check, if I simply wanted the GID to be printed to the index page, and a flag to be set, printing "yay it works" if GID is one of 2,3,4 or 6, how would I do this?
(I reveal my total ignorance here - the only coding I have ever done was in basic! many years ago!)
Cheers
The code works fine for me, so I really don't know why it's failing for you.
I guess you could try:
Code:
<if true then>{$shoutbox}</if>
|
to see if conditionals work at all.
Otherwise, if you can set up a clean test board and provide the exact steps to reproduce the issue, I can try looking into it for you.