BuddyPress templates are tricky, I was adding a user icon to a menu bar, and I needed to print a link to the current user profile page. Using the ‘bp_core_get_user_domain’ function you can get the link to any profile page, by passing the user ID as an argument. Since I wanted the link to the current user I used the WordPRess function ‘wp_get_current_user’ to get the user object.
$user_url = '';
$logged_in = FALSE;
if (is_user_logged_in()){
$logged_in = TRUE;
$current_user = wp_get_current_user();
$user_url = bp_core_get_user_domain($current_user->ID);
}
<?php if ($logged_in) { ?>
<a href="<?php echo $user_url ?>"><i class="icon-user"></i></a>
<?php } ?>
Consider liking the page if the snipped helped you.
Cheers!