By default administrator role will redirect to the wp-admin page after login, to force all users to redirect to the front end manager dashboard. copy an paste this code to your theme functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | // Remove the Front end manager hook login redirection remove_filter( 'login_redirect' , 'wpcfe_custom_login_redirect' , 10 ); /* * WPCargo roles * * wpcargo_client * wpcargo_employee * cargo_agent * wpcargo_branch_manager * wpcargo_merchant * wpcargo_driver * */ // Create new hook to redirect all login to front end manager dashboard function my_custom_login_redirect( $redirect_to , $request , $user ) { /* * Redirect Administrator into Frontend Dashboard after login */ // Check if function exist to avoid error if ( function_exists( 'wpcfe_admin_page' ) && in_array( 'administrator' , $user ->roles ) ) { // Redirect to Front end manager dashboard // wpcfe_admin_page() - Frontend Page ID $redirect_to = get_permalink( wpcfe_admin_page() ); } /* * Redirect WPCargo Client in to specific url */ if ( in_array( 'wpcargo_client' , $user ->roles ) ){ // Change the http://your-domain.com in to your actual domain } return $redirect_to ; } add_filter( 'login_redirect' , 'my_custom_login_redirect' , 10, 3 ); |