我正在使用WordPress 3.7.1开发一个网站,并尝试在登录时通过redirect_to URL参数重定向用户.
我已经验证登录表单后端看到redirect_to GET参数,并且登录提交包含redirect_to POST值...但那些东西不起作用.
删除了链接和用户凭据
登录后(对于我的Admin acct和本帖中提供的订阅者帐户),用户将被带到WP仪表板而不是redirect_to参数中的URL.
我确实设置了allowed_redirect_hosts,并在自定义插件文件中使用以下代码(这就是这个).
add_filter( 'allowed_redirect_hosts' , 'glue_allowed_redirect_hosts' , 10 ); function glue_allowed_redirect_hosts($content){ $content[] = 'app.realestategradschool.com'; $content[] = 'dev-app.realestategradschool.com'; $content[] = 'app.realestategradschool.local'; return $content; }
我已经禁用了所有其他插件,试图对此进行故障排除.
编辑:我不能使用login_redirect,因为我不打算重定向所有登录...只有当访问者从其他站点发送到登录页面时(使用oAuth将其登录... oAuth工作...只是没有重定向)
编辑:工作解决方案:
function glue_login_redirect($redirect_to,$request='',$user=null){ //using $_REQUEST because when the login form is submitted the value is in the POST if(isset($_REQUEST['redirect_to'])){ $redirect_to = $_REQUEST['redirect_to']; } return $redirect_to; } add_filter('login_redirect','glue_login_redirect',999);
Bilal.. 7
你可以使用login_redirect
过滤器.请参见
http://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect
我想这就是你要找的东西.
这通常会重定向所有登录.为了能够仅在您需要时重定向,您可以在URL中使用查询字符串参数.如果参数存在重定向,请检查该参数.
你可以使用login_redirect
过滤器.请参见
http://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect
我想这就是你要找的东西.
这通常会重定向所有登录.为了能够仅在您需要时重定向,您可以在URL中使用查询字符串参数.如果参数存在重定向,请检查该参数.