I tried several approaches and code snippets I found. I added them either to a snippet manager or to the custom PHP of the MainWP Custom Dashboard extension. I did not succeed yet.
All of those did not work for me - anyone knows what could be the reason for this?
function admin_default_page() {
return '/wp-admin/admin.php?page=mainwp_tab';
}
add_filter('login_redirect', 'admin_default_page');
function mainwp_redirect_after_login( $redirect_to, $request, $user ) {
// Check if the user has the MainWP dashboard page as their default dashboard
if ( $user->has_prop( 'default_dashboard' ) && $user->default_dashboard == 'mainwp' ) {
// Redirect the user to the MainWP dashboard
$redirect_to = admin_url( 'admin.php?page=mainwp_tab' );
}
return $redirect_to;
}
add_filter( 'login_redirect', 'mainwp_redirect_after_login', 10, 3 );
Does anyone know if this still works? Obviously I tried all of the approaches already. Hence, I am not sure if something is wrong on my site or if it just does not work anymore. I would wonder though, as the site has nothing else installed than MainWP and WPCodeBox
I found it … I forgot I had Branda plugin installed as well for the login screen. Somehow Branda interferes that is why the code did not work. So it seems I can just set redirects after login within Branda as well which works.