Skip to:
Content
Pages
Categories
Search
Top
Bottom

display user photos


  • nobody
    Participant

    @iduy

    I have a code display a name user login on menu, but i having trouble displaying profil photo on menu to, anyone can help me ??

    add_filter( ‘wp_nav_menu_objects’, ‘username_in_menu_items’ );
    function username_in_menu_items( $menu_items ) {
    foreach ( $menu_items as $menu_item ) {
    if ( strpos($menu_item->title, ‘#profile_name#’) !== false) {
    if ( is_user_logged_in() ) {
    $current_user = wp_get_current_user();
    $user_public_name = $current_user->display_name;
    $menu_item->title = str_replace(“#profile_name#”, $user_public_name, $menu_item->title );
    } else {
    $menu_item->title = str_replace(“#profile_name#”, “Anonim”, $menu_item->title );
    }
    }
    }

    return $menu_items;
    }

    And put #profile_name# on menu…

  • You must be logged in to reply to this topic.
Skip to toolbar