WordPress: Redirect Users After Log In

First, the code…

// Redirect admins to the dashboard and other users elsewhere
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
function my_login_redirect( $redirect_to, $request, $user ) {
	// Is there a user?
	if ( is_array( $user->roles ) ) {
		// Is it an administrator?
		if ( in_array( 'administrator', $user->roles ) )
			return home_url( '/wp-admin/' );
		else
			return home_url();
			// return get_permalink( 83 );
	}
}

Then, some explanation…

For more information on this filter, read up on the login redirect filter.

In short, this function sends administrators to the WordPress Dashboard after log in and everyone else to the homepage of the site. To send everyone else to a specific page on your site, replace the id ’83’ to the id of the page. Don’t forget to comment and uncomment the necessary lines.