Title: Admin bar linking problem
Last modified: August 20, 2016

---

# Admin bar linking problem

 *  Resolved [barrypress](https://wordpress.org/support/users/barrypress/)
 * (@barrypress)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/)
 * I added a custom menu to my admin bar, but when I try to add dynamic links to
   let’s say user inbox or activity page with bp_loggedin_user_domain function page
   just refreshes.
    Same links work when I try linking from headher.php but I need
   it in admin bar.
 * this is the code I aded to my functions.php
 *     ```
       function add_sumtips_admin_bar_link() {
       	global $wp_admin_bar;
       	if ( !is_super_admin() || !is_admin_bar_showing() )
       		return;
       	$wp_admin_bar->add_menu( array(
       	'id' => 'sumtips_link',
       	'title' => __( 'Osobno'),
       	'href' => __('< ?php echo bp_loggedin_user_domain()  ?>/messages/sentbox'),
       	));
   
       	// Add sub menu link "View All Posts"
       	$wp_admin_bar->add_menu( array(
       		'parent' => 'sumtips_link',
       		'id'     => 'sumtips_all',
       		'title' => __( 'View All Posts'),
       		'href' => __('http://sumtips.com/all'),
       	));
   
       	// Add sub menu link "Downloads"
       	$wp_admin_bar->add_menu( array(
       		'parent' => 'sumtips_link',
       		'id'     => 'sumtips_downloads',
       		'title' => __( 'Downloads'),
       		'href' => __('<?php echo bp_loggedin_user_domain() ?>activity'),
       		'meta'   => array(
       			'class' => 'st_menu_download',),
       	));
       		$wp_admin_bar->add_menu( array(
       			'parent' => 'sumtips_downloads',
       			'id'     => 'sumtips_browsers',
       			'title' => __( 'Browsers'),
       			'href' => __('http://sumtips.com/downloads?category=3'),
       		));
       }
       add_action('admin_bar_menu', 'add_sumtips_admin_bar_link',25);
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [barrypress](https://wordpress.org/support/users/barrypress/)
 * (@barrypress)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199440)
 * Is that problem caused by the fact that admin bar is defined in wordpress files
   and doesn’t uderstand bp_XXX functions?
    I really can’t undersand what is causing
   this problem, it’s posible that this is a bug.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199441)
 * Not sure if those functions will work but try changing it like so [untested]:
 *     ```
       'href' => bp_loggedin_user_domain().'/messages/sentbox',
       ```
   
 *  Thread Starter [barrypress](https://wordpress.org/support/users/barrypress/)
 * (@barrypress)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199442)
 * It isn’t working, I tried all the variations I coud find on the net like:
    `<?
   php echo bp_loggedin_user_domain() . BP_MESSAGES_SLUG ?>` and bunch of others
   but I can’t get it to work.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199443)
 * The function bp_loggedin_user_domain exists if your code doesn’t throw an error.
   
   Try it with this for testing:
 *     ```
       add_action( 'admin_bar_menu', 'add_sumtips_admin_bar_link', 999 );
   
       function add_sumtips_admin_bar_link( $wp_admin_bar ) {
         global $wp_admin_bar;
   
         if (!is_super_admin() ||  !is_admin_bar_showing() )
       		return;
   
         $args = array(
           'id' => 'sumtips_link',
           'title' => 'Osobno',
           'href' => bp_loggedin_user_domain() . 'messages/sentbox',
         );  
   
         $wp_admin_bar->add_node($args);
       }
       ```
   
 * [http://codex.wordpress.org/Function_Reference/add_node](http://codex.wordpress.org/Function_Reference/add_node)
 *  Thread Starter [barrypress](https://wordpress.org/support/users/barrypress/)
 * (@barrypress)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199444)
 * This is working!! Thanks for your reply.
    I’am still not shure that I understand
   the problem.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199445)
 * I think the problem was you put the ‘href’ in translation functions (`__()`)
   
   [http://codex.wordpress.org/Function_Reference/_2](http://codex.wordpress.org/Function_Reference/_2)
   And this is just a string (not a valid url):
 *     ```
       '<?php echo bp_loggedin_user_domain() ?>activity'
       ```
   
 * I’m glad you got it resolved.
 *  Thread Starter [barrypress](https://wordpress.org/support/users/barrypress/)
 * (@barrypress)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199473)
 * thank you for your explanation.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Admin bar linking problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [barrypress](https://wordpress.org/support/users/barrypress/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/admin-bar-linking-problem/#post-3199473)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
