0

I installed a plugin and want to add the link of the plugin in the toolbar. But I have an issue with the url. The url shows fullname, but I need to show username. I tried replacing fullname in the code with id and domain. But it did not work.

<?php  

  function wsi_menu2(){
    global $bp, $wp_admin_bar;

    // Only show if viewing a user

        // Provides: <body text='black'>
$bodytag = str_replace("Admin", "", $bp->loggedin_user->fullname);

    $wp_admin_bar->add_menu( array(
        'parent' => 'my-account',
        'id'     => 'FacebookInviteFriends',
        'title'  => 'Album',
        'href'   => 'http://mysite.com/members/'.$bodytag.'/album/',
         'onclick' => 'FacebookInviteFriends();'
    ) );
  }

  function wsi_menu3(){
    global $bp, $wp_admin_bar;

    // Only show if viewing a user

        // Provides: <body text='black'>
$bodytag = str_replace("Admin", "", $bp->loggedin_user->fullname);
    $wp_admin_bar->add_menu( array(
        'parent' => 'my-account-friends',
        'id'     => 'my-account-friends-social-invites',
        'title'  => __( 'Send Social Invites', 'buddypress' ),
        'href'   => 'http://mysite.com/members/$bp->loggedin_user->fullname/album/',
         'onclick' => 'FacebookInviteFriends();'
    ) );
    $wp_admin_bar->add_menu( array(
        'parent' => 'my-account',
        'id'     => 'FacebookInviteFriends',
        'title'  => 'Album',
        'href'   => 'http://mysite.com/members/'.$bodytag.'/album/',
         'onclick' => 'FacebookInviteFriends();'
    ) );
  }

Any idea how to make this work for username?

1 Answer 1

0

Try pulling in the username directly from WordPress. I don't think BP will do it for you by default.

global $bp, $wp_admin_bar, $current_user;

$bodytag = str_replace("Admin", "", $current_user->user_login;);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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