Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
–1 vote
in Q2A Core by
Hi. Can anyone advice me on how can i redirect unregistered users to a custom page when they click on a question? For example when a user click on a question at the home page or any other question list (search results, tag results etc) i would like to redirect him to a custom page. How can i do that ??

I think i have to use this function: if (qa_get_logged_in_handle() == null) but i dont know in which file and how can i redirect an unregistered user.

I tried to make some changes to files qa-app-q-list.php and qa-page-questions.php but finished with broken site :(

Can any expert user guide me ??
Thanks in advance
Q2A version: 1.6
Anyone??? I need that function :(

2 Answers

0 votes
selected by
Best answer

Is JavaScript an alternative for you? Provide in the frontend client a JS variable by your PHP script...
registeredUser = 1 //or 0;

Then when page loads, check...and then hijack all question links

if (registeredUser == 0){
  $(".qa-q-item-title a").on("click",function(e){
    //redirect to some place
0 votes
Goto qa-page.php

Goto function qa_get_request_content you will see this snippet.

 elseif (is_numeric($requestparts[0])) {
            $qa_content=require QA_INCLUDE_DIR.'qa-page-question.php';

you can check if qa_get_logged_in_userid() to redirect to user registration
hi @jaipster and thanks for your answer. I added something like that inside the file qa-page.php :

               if (qa_get_logged_in_handle() == null){
            $qa_content=require QA_INCLUDE_DIR.'qa-page-register.php';

But now when a visitor click on ANY LINK at the site  it redirects him on register page. How can i change the code above so it will redirect on register page  if an unregistered visitor click ONLY a QUESTION LINK  ??
Please send me your function qa_get_request_content. Let me have a look and get back to you.