How redirect user after logged in

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.

// 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
    	$redirect_to = "https://your-domain.com/my-page";
    }
    
    return $redirect_to;
}
add_filter( 'login_redirect', 'my_custom_login_redirect', 10, 3 );
0
    0
    Your Cart
    Your cart is emptyReturn to Shop