lexomatic
asked 7 years ago

Is there a way to require users to answer certain fields in DW Question & Answer Pro? For example, I would like to require users to select a question category. Is there a way to add validation so that the form cannot be submitted without this field being answered? 

2 Answers
DominicStaff
answered 7 years ago

 
You can open file wp-content/plugins/dwqa-question-answer/inc/Handle.php and add following code from line 293:

if ( !$category ) {
dwqa_add_notice( __( ‘You must choose category.’, ‘dwqa’ ), ‘error’ );
return false;
}
 if ( !is_user_logged_in() && empty( $_POST[‘_dwqa_anonymous_email’] ) && !is_email( $_POST[‘_dwqa_anonymous_email’] ) ) {
dwqa_add_notice( __( ‘You must enter a valid email.’ ), ‘error’ );
return false;
}
Dominic Staff
replied 7 years ago

Please let me know, if you still face their issue, I will access your site and help you resolve it.

lexomatic
answered 7 years ago

I added this code as directed. It did not work. It does not validate anything. The user can still submit the form without answering the question. Since you sent the first response, I have updated from version 1.0.0 to version 1.0.7. I’m not sure if that matters. 

Dominic Staff
replied 7 years ago

You can replace the code in this file with the following code:
http://snippi.com/s/6nqyynv
Just added this code to the line 378.

lexomatic
replied 7 years ago

We added this code. It did not work. I am still able to submit questions without selecting a category. I would actually like to require the name and address as well as the category. Our developer is also following this thread. Please let us know how to implement this.

Dominic Staff
replied 7 years ago

Please send me your FTP account, I will check and help you resolve this issue.

lexomatic
replied 7 years ago

My FTP account includes access to our online application (not WordPress), which is proprietary. Can you just use my WordPress credentials and edit through the admin interface (https://www.deedclaim.com/wp/wp-admin/).

Dominic Staff
replied 7 years ago

Yes, give me your account of your site via private answer.

Powered by DW Question & Answer Pro