21
Nov
How to add new and change client dashboard menu?
Post in
0 comment
Some time you want to add new or change default theme menu in client dashboard. Then you can use code bellow to add into child theme functions.php file or your custom plugin functions file.
//Dashboard menu remove
add_filter('iwj_get_dashboard_menus', function($menus, $show_on_position) {
$dashboard_url = iwj_get_page_permalink('dashboard');
//Remove menus
unset($menus['applications']);
unset($menus['logout']); //remove logout menu then add it again after add new menus.
$user = IWJ_User::get_user();
//Change default theme menu title
$menus['overview']['title'] = '<span><i class="fal fa-home"></i></span>' . __('User Dashboard', 'injob');
//Add menu for all user
$menus['users-menu'] = array(
'url' => add_query_arg(array('iwj_tab' => 'users-menu'), $dashboard_url),
'title' => '<span><i class="fal fa-video"></i></span>' . __('Users menu', 'injob')
);
//Add menu for employer
if ($user && $user->is_employer()) {
$menus['emp-menu'] = array(
'url' => add_query_arg(array('iwj_tab' => 'emp-menu'), $dashboard_url),
'title' => '<span><i class="fal fa-video"></i></span>' . __('Emp menu', 'injob')
);
}
// Add menu for candidate
if ($user && $user->is_candidate()) {
$menus['cand-menu'] = array(
'url' => add_query_arg(array('iwj_tab' => 'cand-menu'), $dashboard_url),
'title' => '<span><i class="fal fa-video"></i></span>' . __('Cand menu', 'injob')
);
}
//Add logout menu back
$menus['logout'] = array(
'url' => wp_logout_url(home_url('/')),
'title' => '<span><i class="fal fa-sign-out"></i></span>' . __('Logout', 'injob')
);
return $menus;
}, 10, 2);
Incase you want to add new custom page in dashboard, after you add menu with name cand-menu, you can create file wp-content/themes/injob/iwj/dashboard/cand-menu.php then write page content on new file created.