Redirect after Login on WordPress

I'm creating a customized WordPress theme based on an existing site.

I want to use an alternate dashboard which I have created.

How can I have the user directed to 'news.php' after login instead of '/wp-admin/' ?

--

EDIT: Have a working Plug-in for this but the bounty is still availible for anyone who can find a manual way to do this through functions.php, as it would be more secure then using a 3rd party plug-in.

Solutions

The accepted answer is very wrong. One should never be modifying the WordPress Core. Not only will edits be lost at a given update, some changes you make on a whim may compromise other functionality or even endanger the security of your site.

Action Hooks & Filters are included within the core to allow modifying functionality without modifying code.

An example of using the login_redirect filter to redirect certain users can be found here and is a much more robust solution to your problem.

For your specific problem, you want to do this:

function login_redirect( $redirect_to, $request, $user ){
    return home_url('news.php');
}
add_filter( 'login_redirect', 'login_redirect', 10, 3 );

This should solve your problem. Adapted from an answer found here.

Add the following snippet of code in the functions.php file of your theme:

function admin_default_page() {
  return '/new-dashboard-url';
}

add_filter('login_redirect', 'admin_default_page');

This may help. Peter's Login Redirect

Redirect users to different locations after logging in and logging out.

Define a set of redirect rules for specific users, users with specific roles, users with specific capabilities, and a blanket rule for all other users. Also, set a redirect URL for post-registration. This is all managed in Settings > Login/logout redirects.

You can use the syntax [variable]username[/variable] in your URLs so that the system will build a dynamic URL upon each login, replacing that text with the user's username. In addition to username, there is "userslug", "homeurl", "siteurl", "postid-23", "http_referer" and you can also add your own custom URL "variables"...

Tags: PHP / Wordpress / Redirect

Similar questions

Redirect after login in custom login page WP
first sorry for my english i have a problem of redirect an user when he is connected , i make that on a custom login page (modal) when i put to submit i call this code in connexion.php my Ldap works correctly , my insert Works as well and my wp_authenticate('hjhjh', 'cerpcerp'); works also, but the problem is in my_login_redirect( $ie,' ', '1' ) th...
Redirect problem: How to redirect to the original URL after login
I am using BBPress. Links to the forum (for example: https://www.xy.com/topic/test/) are being redirected to a custom login page like so: The users can successfully login, but unfortunately always end up on the same page since the redirect causes a loss of the original URL. Any ideas?
how to change the default login page of wordpress from wp-login.php to custom login page?
how to change the default login page of wordpress from wp-login.php to custom login page. So that any request for login by any user should redirect to custom login page instead of wp-login.php.
replace wp-login.php login forms via a hook & use custom forms with wp-login form validation
I am customizing all the wp-login.php forms, i.e., login, lost password, register, etc. I have a working model but when I decoded to toss in the default error messages on my custom forms I thought there must be a better way to make custom forms and still use wp-login.php to do all the heavy lifting and why write custom form validation when wp-login...
Redirecting users on a custom login & registration page and allowing only admin to login by default wp-login.php
I want users to register & login only by custom pages not by default pages, instead only admin can login by the default wp-login.php I found this .. but it is redirecting login & register both on same page. google.com in this case.
Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
When I try logging in to wp-admin (or even wp-admin/index.php) I simply get redirected to my site's homepage. (after authenticating successfully - i.e. It DOES accept my login credentials (so its not an account, password or blacklisting issue), but simply wont go to the admin dashboard page after login) (I suspect it may be an infinite loop that is...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.