Add User’s Media Link in the WordPress Navigation Menu

Add the following code in your theme’s functions.php file to add user’s media link in WordPress navigation menu. Make sure you have Navigation Menu to be checked in menu settings in Appearance settings.

function my_wp_get_nav_menu_items( $items, $menu, $args ){
    if ( is_user_logged_in() && class_exists( 'RTMedia' ) ) {
        $url = trailingslashit ( get_rtmedia_user_link ( get_current_user_id () ) ) . RTMEDIA_MEDIA_SLUG . '/'; // get user's media link
        // add new menu item to nav menu
        $parent = 0;
        $order = 3;
        $item = new stdClass();
        $item->ID = 1000000 + $order + $parent;
        $item->db_id = $item->ID;
        $item->title = 'Upload photos';
        $item->url = $url;
        $item->menu_order = $order;
        $item->menu_item_parent = $parent;
        $item->type = '';
        $item->object = '';
        $item->object_id = '';
        $item->classes = array();
        $item->target = '';
        $item->attr_title = '';
        $item->description = '';
        $item->xfn = '';
        $item->status = '';
        $items[] = $item;
    }
    return $items;
}
add_filter( 'wp_get_nav_menu_items', 'my_wp_get_nav_menu_items', 99, 3 );