0

I have modified the buddpress admin bar by creating the following plugin which adds a simple text link to the bar:

function bp_adminbar_currentsite_menu() {

global $bp;
?>
<li>
<!-- Insert your link url or relative url, and your link text below -->
<a href="http://EXAMPLE.COM">EXAMPLE LINK TEXT</a>
</li>
<?php
}
// Call The Function Above
add_action('bp_adminbar_menus', 'bp_adminbar_currentsite_menu', 999);

However, I do NOT want the above link to be shown when logged into the wordpress admin backend (so for example when an admin is editing a post). I thought about just doing a php_self check to see if it contained "/wp-admin/" but figured that there has to be a more elegant wordpress/buddypress hook here.

How can I get the above code to only show when you are viewing a normal blog page, NOT in the admin area?

Thanks

0

You ca use the conditional tag is_admin() to check if you are on the front-end or back-end like this:

function bp_adminbar_currentsite_menu() {
    global $bp;
    if (!is_admin()){
        ?>
        <li>
        <!-- Insert your link url or relative url, and your link text below -->
        <a href="http://EXAMPLE.COM">EXAMPLE LINK TEXT</a>
        </li>
        <?php
    }
}
// Call The Function Above
add_action('bp_adminbar_menus', 'bp_adminbar_currentsite_menu', 999);
  • thanks, is_admin() is exactly what I was looking for. I added the if statement to the "add_action" instead, just FYI, thanks again. I also asked the same question on SO here if you want to copy and paste your answer: stackoverflow.com/questions/5461330/… – themerlinproject Mar 29 '11 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.