Skip to content

Instantly share code, notes, and snippets.

@KhanMaytok
Created July 14, 2015 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KhanMaytok/bc46a876e09c65bb38cd to your computer and use it in GitHub Desktop.
Save KhanMaytok/bc46a876e09c65bb38cd to your computer and use it in GitHub Desktop.
Add profile photo to wordpress menu
<?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) {
$myavatar = bp_core_fetch_avatar( array(
'item_id' => bp_loggedin_user_id(),
'width' => 50,
'height' => 50,
'class' => 'avatar',
)
);
if (!is_user_logged_in())
return $menu;
else
//$profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('Visit your Awesome Profile') . '</a></li>';
$profilelink = '<li>' . $myavatar . '</li>';
$menu = $menu . $profilelink;
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment