Hi. How can we help?

How remove the Dashboard page from the WordPress backend and direct the vendor to report after login

To remove the Dashboard page from the WordPress backend and direct the vendor to report after login add this code in the functions.php of your theme:

 

if( function_exists( 'YITH_Vendors' ) ){
function yith_wpv_vendor_to_remove_menu_items( $to_remove ){
$vendor = yith_get_vendor( 'current', 'user' );
if( $vendor->is_valid() && $vendor->has_limited_access() ){
$to_remove[] = 'index.php';
}
return $to_remove;
}

function yith_wcmv_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if ( in_array( YITH_Vendors()->get_role_name(), $user->roles ) ) {
$redirect_to = esc_url( add_query_arg( array( 'page' => 'wc-reports' ), admin_url( 'admin.php' ) ) );
}
}
return $redirect_to;
}
add_filter( 'yith_wpv_vendor_to_remove_menu_items', 'yith_wpv_vendor_to_remove_menu_items' );
add_filter( 'login_redirect', 'yith_wcmv_login_redirect', 10, 3 );
}
Was this article helpful?
1 out of 5 found this helpful

Back to Help Center >