Add Media Link to User Profile in Menu with rtMedia

Intro

In order to have a menu item in the User Nav Menu going to the Media page in the User Profile, you have to add a custom link in the menu:

/members/me/media

In order to get the link to work, you need to add the following to your functions.php:

/* Function to add Media to User Menu in Profile page with rtMedia */

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 );

This can be found on this page.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *