harsh deshmukh
asked 11 years ago

Hi There,
I want to authenticate the user If he/she press the button Ask A Question. 
If the user is not logged in he/she should navigate on login page and once he is logged in, he should redirected here.
I have below code to navigate the user on authentication page.
<?php
if(is_singular())
{
if(!is_user_logged_in())
{
auth_redirect();
}
}?>
  Can you please suggest how we can achieve it using above script or by any different way.
Url: http://harsh031.0fees.net/dwqa-questions/
http://harsh031.0fees.net/dwqa-ask-question/
Regards,
Harsh

2 Answers
DominicStaff
answered 11 years ago

Hi Harsh !
Please copy “dw-question-answer/inc/templates/default/archive-questions.php” to “<your-theme-folder>/dwqa-templates/archive-questions.php”
Then at line 30 and 242 you can modify the code with your own one.
Please try and let us know the results!

harsh deshmukh
replied 11 years ago

Hi Dominic,

Thanks for quick help.
I added my code on dw-question-answer/inc/templates/default/submit-question.php now submit-question.php file looks like below:

<?php
if(is_singular())
{
if(!is_user_logged_in())
{
auth_redirect();
}
}?>
<?php get_header('dwqa'); ?>

<?php do_action( 'dwqa_before_page' ) ?>

<?php dwqa_submit_question_form(); ?>

<?php do_action( 'dwqa_after_page' ) ?>

<?php get_footer('dwqa'); ?>

this way I found easy and this is working fine. Thanks for your support.

Regards,
Harsh

Hammer Time
replied 11 years ago

This worked great but we’d like to change the button text to ‘Login to Ask a Question’ if not logged in and realize we would need to change the text in this function (dwqa_get_ask_question_link)
if(is_user_logged_in()) {
$label = $label ? $label : __(‘Ask a question’,’dwqa’);
} else {
$label = $label ? $label : __(‘Login to ask a question’,’dwqa’);
}
Is there a way to override this function in our child template to avoid overwriting our changes when doing a dwqa update?

Powered by DW Question & Answer Pro