Page 1 of 1

customizing what gets shown and how...

PostPosted: September 5th, 2011, 2:46 pm
by godrob
Hi guys,

I'm trying to hide a chat script from appearing on my buddypress site under certain conditions. The conditions are:

1) Only level 1 members and higher can see the chat script.
2) The chat script shouldn't appear on any of my payment pages.

So, I added the code below to my themes header.php file:

Code: Select all
<?php if(current_user_can("access_s2member_level1") OR (!is_page( array( 100, 1773, 1791, 1778, 1784 ) ) ) ) {
               
            echo '<link type="text/css" rel="stylesheet" id="arrowchat_css" media="all" href="/arrowchat/external.php?type=css" charset="utf-8" />';
       echo '<script type="text/javascript" src="/arrowchat/includes/js/jquery.js"></script>';
            echo '<script type="text/javascript" src="/arrowchat/includes/js/jquery-ui.js"></script>';
              
             }
            ?>


However the chat script still shows. But if I isolate the code to just one query ie, use just
current_user_can or !is_page they work fine independently, but combined together it doesn't work

What am I doing wrong?

Thanks
Rob.

Re: customizing what gets shown and how...

PostPosted: September 6th, 2011, 10:20 pm
by Cristián Lávaque
You should use AND instead of OR. Using OR, if the user can access level 1, the condition will be true in the first statement, if you use OR it'll be true only if he can access level 1 and it isn't one of those pages. If it's one of those pages, you don't want to show even if he can access level 1. See?

I hope that helps. :)