Hi Emilie,
Yes it does work on my site, but needed another setting to be added to the function, which I have added below. However, it will only show up in the menu when in a course page as the gradebook relates to the course the user is enrolled into,
/*
* This code adds the My Dashboard
* functionality to the custommenu.
*/
global $CFG, $COURSE, $USER;
$hasdisplaymydashboard = (empty($this->page->theme->settings->displaymydashboard)) ? false : $this->page->theme->settings->displaymydashboard;
if (isloggedin() && !isguestuser() && $hasdisplaymydashboard) {
$branchlabel = '<i class="fa fa-dashboard"></i> '.get_string('mydashboard', 'theme_essential');
$branchurl = new moodle_url('/my/index.php');
$branchtitle = get_string('mydashboard', 'theme_essential');
$branchsort = 10001;
$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
$branch->add('<em><i class="fa fa-user"></i> '.get_string('profile').'</em>',new moodle_url('/user/profile.php'),get_string('profile'));
$branch->add('<em><i class="fa fa-calendar"></i> '.get_string('pluginname', 'block_calendar_month').'</em>',new moodle_url('/calendar/view.php'),get_string('pluginname', 'block_calendar_month'));
// Check if messaging is enabled.
if (!empty($CFG->messaging)) {
$branch->add('<em><i class="fa fa-envelope"></i> '.get_string('pluginname', 'block_messages').'</em>',new moodle_url('/message/index.php'),get_string('pluginname', 'block_messages'));
}
// Check if badges are enabled.
if (!empty($CFG->enablebadges)) {
$branch->add('<em><i class="fa fa-certificate"></i> '.get_string('badges').'</em>',new moodle_url('/badges/mybadges.php'),get_string('badges'));
}
// Check if a course id exists.
if (!empty($COURSE->id)) {
if (($COURSE->id) >=2) {
$branch->add('<em><i class="fa fa-book"></i> '.get_string('grade').'</em>',new moodle_url('/grade/report/user/index.php?id='.$COURSE->id),get_string('grade'));
}
}
$branch->add('<em><i class="fa fa-list-alt"></i> '.get_string('forumposts', 'mod_forum').'</em>',new moodle_url('/mod/forum/user.php?id='.$USER->id));
$branch->add('<em><i class="fa fa-list"></i> '.get_string('discussions', 'mod_forum').'</em>',new moodle_url('/mod/forum/user.php?id='.$USER->id.'&mode=discussions'));
$branch->add('<em><i class="fa fa-sign-out"></i> '.get_string('logout').'</em>',new moodle_url('/login/logout.php'),get_string('logout'));
}