Fauzie Bachri
asked 8 years ago

Hi,

as subject can you help on how to make Question list page shown automatically after question is posted by user, currently its directly open a single question page

Thanks,
Fauzie

2 Answers
DominicStaff
answered 8 years ago

Hi,
To redirect users to a different page or list questions when user submit a answer, please open the wp-content/plugins/dw-question-answer/inc/action.php file. Find the line 128.
Find the line code around line 128:
wp_redirect( get_permalink( $question_id ) );

Then replace it with the following code:
wp_redirect('https://your-site.com');

To redirect users to a different page when user submit a question, please open the actions.php file in the folder path wp-content -> plugins -> dw-question-answer -> inc -> actions.php.
Find the line code around line 511:

exit( wp_safe_redirect( get_permalink( $new_question ) ) );

Then replace with the following code to redirect to home page:

exit( wp_safe_redirect( home_url() ) );

Notice: you can use similar to redirect user to any other page as you wish (in your case to the question listing page)

Eg: like this is my url : http://mysite/discussion-forum/
exit( wp_safe_redirect( home_url() .'discussion-forum/' ) );

Hope this helps !

dominic Staff
replied 8 years ago

We have some changes in the latest version. Please do as the following:

To redirect users to a different page or list questions when user submit a answer, please open the wp-content/plugins/dw-question-answer/inc/Posts/Answer.php file. Find the line 408.
Replace the following code:

// wp_redirect( get_permalink( $question_id ) );
// wp_send_json_success( array( 'url' => get_permalink( $question_id ) ) );
// return true;

With new code:

wp_redirect('https://your-site.com');
wp_send_json_success( array( 'url' => get_permalink( $question_id ) ) );
return true;

To redirect users to a different page when user submit a question, please open the Question.php file in the folder path wp-content -> plugins -> dw-question-answer -> inc -> Post -> Question.phpfile. Find the line code around line 439: exit( wp_safe_redirect( get_permalink( $new_question ) ) );`

Then replace with the following code to redirect to home page:
exit( wp_safe_redirect( home_url() ) );

Notice: you can use similar to redirect user to any other page as you wish (in your case to the question listing page)

Eg: like this is my url :http://mysite/discussion-forum/
exit( wp_safe_redirect( home_url() .'discussion-forum/' ) );

About the permalink of categories, have you tried to add the permalink in the Settings of Q&A

yashwantnaik
answered 7 years ago

Hello Friends,
Above function wont work as developer change the functions and file names.
here is solution to redirect the page when anybody submit the new questions –

  1. Find the file name Handle.php
  2. Open the file and look for code –  dwqa_add_notice( __( ‘Your question is waiting moderator.’, ‘dwqa’ ), ‘success’ ); } else {
  3. Remove the above code
  4. Now edit code – exit(); to exit( wp_safe_redirect(‘http://www.domain.com/page-url/‘) );    

Now test online by submitting new question – the page will redirect to your desire page.
Hence forward dont update the Plugin as by reading this post developer may change functions 😛
Thank you,
Yashwant Naik

Powered by DW Question & Answer Pro