Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile menu new tab/link


  • bertl11
    Participant

    @bertl11

    Hello,

    I managed to add a new tab to the bp menu with the following code:

    function bpfr_menubar_link() {
    	global $bp;
    
    	$bp->bp_nav[$slug] = array(
    			
    			'name'     => 'Fotos, Videos',
    			'slug'     => 'super_link',
    			'link'     => 'http://test.com/test',
    			'css_id'   => 'super-link',	
    			'position' => 30
    		);
    }
    add_action( 'bp_core_new_nav_item', 'bpfr_menubar_link', 999 );

    But now I want to add this code as link:
    <a href="<?php echo home_url() . '/' . get_the_author_meta( 'user_login', wp_get_current_user()->ID ). '-kalender' ; ?>" >Kalender</a>

    How can I add this link so that it’s displayed as tab in the menu?

    Thanks a lot for your help

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

  • shanebp
    Moderator

    @shanebp

    Try creating a variable. Something like:

    $my_link = '<a href="' . bp_loggedin_user_domain() . '/kalender">Kalender</a>';
    
    ...
    'link'     => $my_link,
    ...

    bertl11
    Participant

    @bertl11

    Hello shanebp,

    thanks for your help!

    I changed the code but it’s not working. Did I insert the code in the correct position?

    function bpfr_menubar_link() {
    	global $bp, $my_link;
    	$my_link = '<a href="' . bp_loggedin_user_domain() . '/kalender">Kalender</a>';
    
    	$bp->bp_nav[$slug] = array(
    			
    			'name'     => 'Kalender',
    			'slug'     => 'super_link',
    			'link'     => '$my_link',
    			'css_id'   => 'super-link',	
    			'position' => 30
    		);
    }
    add_action( 'bp_core_new_nav_item', 'bpfr_menubar_link', 999 );

    The output is http://test.com/members/username/$my_link

    Thanks for your help


    shanebp
    Moderator

    @shanebp

    Why did you add quotes to the variable and turn it into a string?
    'link' => $my_link,


    bertl11
    Participant

    @bertl11

    Hi,

    first I tried it without the quotes and also that didn’t work. The output then was:
    http://test.com/members/username/<a href=
    That’s why I tired it with the quotes.

    Would be great if you can help me with that. Thanks a lot for your help!


    shanebp
    Moderator

    @shanebp

    Ok, try:
    $my_link = bp_loggedin_user_domain() . '/kalender';


    bertl11
    Participant

    @bertl11

    OK, thanks for your help!


    leefalcas
    Participant

    @leefalcas

    I can tell if I run I’m trying to do the same but I get error 404

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar