开发者

wordpress redirect to subdomain after login

I have my wordpress blog at www.mysite.com , also I have my own php application at a subdomain l.mysite.com

I want the login credentials of WordPress in my PHP application. I figured out that by including the wp-blog-header.php from the root to my app.

I can use the user info OK.

I wanted to redirect users to www.mysite.com/wp-login.php?redirect_to=l.mysite.com . You can see here that I am specifying the redirect_to parameter. Wordpress ignores this and redirects to admin panel.

I think that worpdress doesn't allow redirect to an "external domain" , which I think is specified in wp_safe_redirect() function in wordpress. Is there any plugin which could ignore some domain to which redirect can happen?

I see that there are many开发者_StackOverflow中文版 login specific redirect plugins but none which could do to a new doamin.


Check this Plugin: http://www.theblog.ca/wplogin-redirect

Looks like it does what you want. Probably it's outdated, however, it should be trivial to create a plugin that fits your need.

A filter to start with is login_redirect, there is another filter in wp_safe_redirect() so you can prevent the domain you want to use being blocked.

To monitor redirects, checkout my Better HTTP Redirects Plugin.


+1 to @hakre . I don't have 15 rep so I can't upvote. Repost incase his

function cleanup_allowed_redirect_hosts( $hosts )
{
    $allowed_hosts = array('first.domain.com', 'second.domain.com', 'etc.domain.com');
    return array_merge( $hosts, $allowed_hosts );
}

add_filter( 'allowed_redirect_hosts', 'cleanup_allowed_redirect_hosts', 10, 1 );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜