Sign Up! Login: Password: New User? Forgot? Support
Code 
 
 
Forums 
Forums : Shout > Hiding the Shoutbox from Non-Members
Innocandy (Applicant) 1/13/2010 11:21 PM EST : shoutbox

Innocandy
Posts: 461

0
Like

0
Dislike

is there anyway to make the shoutbox feature only viewable by members. atm it is located on my forum page. the only opinions i can see to change this is by making the whole forum page only viewable by members. is there a way to make only the shoutbox not viewable to the public?
TopBottom

Mottie (SuperAdmin) 1/14/2010 6:59 AM EST : Hiding shoutbox
ACK!
Mottie
Posts: 3884

0
Like

0
Dislike

Hi Innocandy!

Yes it is possible!

Hiding the Shout Box from Non-Members

GuildPortal admin site link to original post

This script reveals a hidden shout box. So what that means is anyone can view the page source and still see the shout box contents... if you want to completely remove the shout box, then that will take another bit of coding (included at the end).

Coding
To start out, you will need to hide te shout box. The CSS at the top of the code does that. while the script will reveal the code if it doesn't find a link to join the site. Add the complete code below to your Footer Area (Control Panel > Custom HTML & Script > Footer Area).
<!-- *** Reveal shout box if the link to join the site doesn't exist *** -->
<style type="text/css">
 .gpWidget-shout { display: none; }
</style>
<script type="text/javascript">
$(document).ready(function(){
 var accessLevel = "$block[userlevelname]";
 if (!accessLevel.match('public|associate')) $('.gpWidget-shout').show();
})
</script>
If you want to completely remove the shoutbox (personal preference I guess), then add this code:
<!-- *** Reveal shout box if the link to join the site doesn't exist, otherwise remove it *** -->
<style type="text/css">
 .gpWidget-shout { display: none; }
</style>
<script type="text/javascript">
$(document).ready(function(){
 var accessLevel = "$block[userlevelname]";
 if (accessLevel.match('public|associate')) {
  $('.gpWidget-shout').remove();
 } else {
  $('.gpWidget-shout').show();
 }
})
</script>
Customizing
  • Modify the access level by changing the code in blue. Any additional access level names should be separated with a pipe "|" (shift-\, above the enter key on the keyboard). Here are some examples:

     Access Levels 
        
     Hide Shout box from  Code
      Public
      Associate
      Member
      Council
      Officer
      Super Admin
       Public  'public'
       Public & Associates  'public|associate'
       Public, Associates & Members  'public|associate|member'

  • The code is using a new variable "$block[userlevelname]" which provides the access level name in lower case.
Edit (1/22/2010): Updated the code to look for "membership is pending review" in the top menu and if found, it won't show the shout box. NOTE: this feature doesn't work if you are using a Navigation type of "Content Box - Left Side, Center or Right Side".
Edit (1/31/2010): Updated to use the new $block code that provides the user access level.
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

Innocandy (Applicant) 1/14/2010 4:55 PM EST : RE: Hiding shoutbox

Innocandy
Posts: 461

0
Like

0
Dislike

awesome thanks
TopBottom

Innocents2 (Member) 1/21/2010 7:58 PM EST : RE: Hiding shoutbox

Innocents2
Posts: 2

0
Like

0
Dislike

how do i make it so the shout box is only viewable to MEMBERS and up... not applicants??

Characters: Innocents
TopBottom

Mottie (SuperAdmin) 1/22/2010 8:15 AM EST : RE: Hiding shoutbox
ACK!
Mottie
Posts: 3884

0
Like

0
Dislike

Hi Innocents2!

I've updated the code to ignore non-members as well as applicants. Sadly if you choose a Navigation Type of "Content Box - Left Side", "Content Box - Center" or "Content Box - Right Side" (Control Panel > Style Tools > Navigation Type) it won't work properly for applicants.
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

Mottie (SuperAdmin) 2/1/2010 1:06 AM EST : RE: Hiding shoutbox
ACK!
Mottie
Posts: 3884

0
Like

0
Dislike

Updated to use the new $block variables that show the user's access level.
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

 
 
Key 
New posts No new posts
New posts ( popular ) No new posts ( popular )
New posts ( sticky ) No new posts ( sticky )
New posts ( locked ) No new posts ( locked )
 
 
Who's Online 
There are   members online.
 
 
So-and-so has logged on!
%title%
%message%