Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] BuddyPress Links URLs


  • Famous
    Participant

    @famous

    Does someone know how to specify buddy press urls? For instance:
    <?php echo esc_url( home_url( '/' ) ); ?>
    the above is to point to WordPresses homepage.

    But what is the url for a buddypress’s profile, sites, etc… page?

    Thank you!

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

  • danbp
    Moderator

    @danbp

    Hi @famous,

    anything directly related to URL for bp is listed here:
    http://hookr.io/plugins/buddypress/#index=l&search=url

    In most case, you can built a link by array, which generally extend pre existing parameters. It’s very variable and depend where and how the link shoud work.

    Here some exemple snippets to add a link to a member’s profile.

    /* add external link on buddy menu bar */
    function bpfr_menubar_link() {
    global $bp;
    
    if ( !is_user_logged_in() )
        return false;
    
    $link = bp_get_loggedin_user_link();
    
    	$bp->bp_nav[$slug] = array(
    			'name'                    => 'View my profile',
    			'slug'                    => 'super_link',
    			'link'                    => $link,
    			'css_id'                  => 'super-link',	
    			'position'                => 20
    		);
    }
    add_action( 'bp_core_new_nav_item', 'bpfr_menubar_link', 999 );
    
    /* link to profile on SWA page */
    function goto_my_profile_tab() {
      if ( !is_user_logged_in() )
        return false;
    
      if ( bp_is_active( 'xprofile' ) )
    
        echo '<li><a href="'. bp_get_loggedin_user_link() .'">View my profile</a></li>';
      
    }
    add_action( 'bp_activity_type_tabs', 'goto_my_profile_tab' ); // SWA page
    add_action( 'bp_members_directory_member_types', 'goto_my_profile_tab' ); // members directory page
    
    /* shortcode linking to profile [xyz] */
    function bpfr_link_to_profile() {	
    return '<a href="'. bp_get_loggedin_user_link() .'">View my profile</a>';			
    }
    add_shortcode( 'xyz', 'bpfr_link_to_profile' );

    Another technique for groups here.

    In hope this will help you to go further.


    Famous
    Participant

    @famous

    Exactly what I needed, thanks @danbp

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