How To: Redirect A User After Logging Into WordPress

A common question I’ve seen is how can you redirect a user to a specific URL after they login to WordPress. Maybe you want to hide the Admin Dashboard from your users, so redirecting them to the home page after logging in is a great way to do this. Just place the below code in your themes functions.php file:

add_action('login_form', 'redirect_after_login');

function redirect_after_login() {
	global $redirect_to;
	if (!isset($_GET['redirect_to'])) {
		$redirect_to = get_option('siteurl');

The preceding code snippet will redirect any user who logs in to the home page (siteurl) of WordPress. You can easily set any redirect URL you want by changing the value of the $redirect_to variable. This function also verifies that the redirect_to querystring doesn’t exist before setting the redirect URL.

It’s as easy as that! Now you can easily control where your users are redirected to when they login to WordPress.