Created
July 14, 2015 18:05
-
-
Save KhanMaytok/bc46a876e09c65bb38cd to your computer and use it in GitHub Desktop.
Add profile photo to wordpress menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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