I'm working on a web site with WordPress 3.7.1 and trying to redirect a user upon login via the redirect_to URL parameter.
I've verified that the login form backend sees the redirect_to GET parameter, and that the login submission includes the redirect_to POST value...but thats where things don't work.
Removed link and user credentials
Upon login (for both my Admin acct and the Subscriber acct provided in this post), the user is taken to the WP dashboard instead of the URL in the redirect_to parameter.
I do have the allowed_redirect_hosts being set, with the following code in a custom plugin file (which is pretty much just this).
add_filter( 'allowed_redirect_hosts' , 'glue_allowed_redirect_hosts' , 10 );
$content = 'app.realestategradschool.com';
$content = 'dev-app.realestategradschool.com';
$content = 'app.realestategradschool.local';
//using $_REQUEST because when the login form is submitted the value is in the POST
$redirect_to = $_REQUEST['redirect_to'];
You can use
login_redirect filter. See here
I think this is what you are looking for.
This will normally redirect all logins. To be able to redirect only when you want, you can use a query string parameter in the URL. Check for the parameter, if it exists redirect.