how do i set a 'PROFILE' menu tab that goes to a buddypress members profile?

what is says in the title. can I have * explicit * instructions on how to set a menu tab on my site (http://www.mythica.intothemythica.com) that will go to a logged in user's profile page?

  • Rupok

    Hi Griffin, thanks for asking.

    Well, the following function will provide you the currently logged in user profile link when BuddyPress is installed and activated:
    <a href=”<?php echo bp_loggedin_user_domain(); ?>”>My Profile</a>
    Now where you want to show this is the fact. You said you want to set a menu tab, but I'm afraid, I'm not sure exactly where you want to put this link. Do you want to add this in the main navigation menu? Or do you want to create a tab beside "All Members" and put the link there? Can you please specify? We can give you proper code as soon as we are clear about the position.

    I'm looking forward to hear from you and resolve this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Rupok

    Hi Griffin,

    You can do this by creating a MU Plugin. For creating a MU Plugin, create a folder named "mu-plugins" inside your "wp-content" folder. Then inside that "mu-plugins" folder, create a file with any name and with a .php extension. Now paste the code inside that file and save.

    <?php
    // Filter wp_nav_menu() to add profile link
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
    function my_nav_menu_profile_link($menu) {
    	if (!is_user_logged_in())
    		return $menu;
    	else
    		$profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My Profile') . '</a></li>';
    		$menu = $menu . $profilelink;
    		return $menu;
    }

    For getting more idea on mu plugins, you can go through this article: http://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    I've tested this and it's working fine on my test site. Please let us know if you have any confusion or if you are stuck at any point. We will be glad to help further.

    Have a nice day. Cheers!
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.