Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
2.4k views
in Q2A Core by
I have a question2answer installation in a subdirectory /forums/ of my wordpress installation. I am using Wordpress integration, so users must be logged into Wordpress before accessing the forum. My problem is that when I try to access a link, for example https://www.test.com/forums/1511/question-title-on-forum, I am redirected to https://www.test.com/wp-login.php (as expected) but after logging in, I am redirected to the Wordpress home page https://www.test.com/ rather than the forum page I was originally trying to access.

Is it possible to be redirected to the forum page after logging in instead? With other pages on my Wordpress installation, a $_GET['redirect_to'] parameter is specified, which I assume is what causes the redirection after login. My .htaccess in the forums subdirectory currently contains a line that sets $_GET['qa-rewrite'] to "1511/question-title-on-forum" but the $_GET array is unset in qa_index_set_request(). The same data ends up in $_REQUEST['qa-rewrite'] but I haven't actually been able to track down the point at which the redirection to wp-login.php occurs.

Note: problem was originally encountered on version 1.5.1 but is still there on 1.6.3
Q2A version: 1.5.1

1 Answer

+1 vote
by
selected by
 
Best answer

there are two possibilities:

1. redirect link is not generated

2. wordpress doesn't redirect back to Q2A


Solutions:

1: login link should be targeted like this:

test.com/login?redirect_to=http://test.com/forums/1511/question-title-on-forum

if it's not the case, it's because your theme or one of plugins has re-created login link and it's not compatible with WP integration.

2: if the link is correct, then only explanation is that either you did not follow integration instruction(step 6) or you have a plugin or security config which interferes with WP's login process. I suggest using "Theme My Login" plugin or checking other options.

by
Thanks for your help. It was the first of the two possibilities. I found a call in a custom header to wp_redirect(wp_login_url()) which was stripping the redirect information. Changing this to an auth_redirect() solved the issue.
...