vicahto
asked 7 years ago

That’s the message I get when when I try to ask a question as anonymous. How can I make it ask the anonymous user  to login or register instead?

I tried adding this code to the single-question.php file but then, the questions refused to display

<?php
if ( dwqa_current_user_can( 'post_answer' ) ) {
dwqa_load_template( 'answer', 'submit-form' );

} else { ?>

<?php if ( is_user_logged_in() ) { ?>

<div class="alert"><?php _e( 'You do not have permission to submit answer.','dwqa' ) ?>

<?php } else { ?>

<h3 class="dwqa-title">

<?php

printf( '%1$s <a href="%2$s" title="%3$s">%3$s %4$s', **( 'Please login or', 'dwqa' ), wp_registration_url(), **( 'Register', 'dwqa' ), __( 'to Submit Answer', 'dwqa' ) );

?>

<div class="login-box">

<?php wp_login_form( array( 'redirect' => get_post_permalink( $question_id ) ) ); ?>

<?php

}

}

?>

Pls help

1 Answers
Allen
answered 7 years ago

Hi, so sorry for my late reply, have you go to dashboard >> Question >> settings >> permission and check the permission for anonymous to post question ?

vicahto
replied 7 years ago

Yes, when I do that, it allows anonymous users to post questions. But I want it to ask them to register first before they can post. I don’t want anonymous users posting questions.

Allen
replied 7 years ago

well you can uncheck that permission. If you use the pro version of the DW Q&A, the login form well be shown, how ever if you use the free version, only a notice will show that they not have permission to ask question.

vicahto
replied 7 years ago

Alright Allen. Thanks for your timely response.

Allen
replied 7 years ago

Hi, this link to question can help you add the login form to the single question page :
https://www.designwall.com/question/login-option-is-missing-on-the-single-question-page-how-do-i-add-it/

and to add question login form to the ask question page, you can replace file : dw-question-answer/templates/question-submit-form.php with this code from here :
http://pastebin.com/cC207Qzi

vicahto
replied 7 years ago

Thanks again allen. I’ll try it out and get back to you.

vicahto
replied 7 years ago

Are you saying I should replace the code in this file (dw-question-answer/templates/question-submit-form.php) with the code from the pastebin link u provided? Should I replace the entire code? Or just a portion of it

Allen
replied 7 years ago

Yes you can replace the entire code.

Do An Duy
replied 6 years ago

Hi,

I use the Pro version and I tried unchecking that option but no login form is shown. Can you please help me?

tkwes02
replied 6 years ago

(dw-question-answer/templates/question-submit-form.php) – where is this directory located? i dont see the dw-question-answer folder in the directory.

tkwes02
replied 6 years ago

(dw-question-answer/templates/question-submit-form.php) – where is this directory located? i dont see the dw-question-answer folder in the directory.

Powered by DW Question & Answer Pro