aleckzer
asked 8 years ago

After hours trying to set Minimum characters for  Titles and descriptions user has to write to publish the question – no way through.
Give a hand? Which command in Session.php file?
Thanks.

aleckzer
replied 8 years ago

I tryed ” if ( strlen($_POST[‘question-title’]) < 30) { " in Handle.php – worked preaty fine for titles.
Then tryed " if ( strlen( $_POST['question_id']) < 300) { " in Handle.php – Did not work to limit minimum characters for question.
Also… how to limit maxmium for question-title ? tryed:
if ( strlen($_POST['question-title']) < 30) { – under first code above – and got error.
I'm not so good using php.
Hand here..

aleckzer
replied 8 years ago

if ( isset( $_POST[‘_wpnonce’] ) && wp_verify_nonce( esc_html( $_POST[‘_wpnonce’] ), ‘_dwqa_submit_question’ ) ) {
if ( $valid_captcha ) {
if ( strlen($_POST[‘question-title’]) < 30) {
dwqa_add_notice( __( 'Escreveu pouco gay.', 'dwqa' ), 'error' );
return false;
}

it's like that now. I just changed empt for strlen and add < 30

aleckzer
replied 8 years ago

So…
how to to limit maxmium for question-title ?
and minimum characters for question field?

aleckzer
replied 8 years ago

Tryed to change:
if ( empty( $_POST[‘question_id’] ) ) {
dwqa_add_notice( __( ‘Question is empty’, ‘dwqa’ ), ‘error’ );

to:
if ( strlen( $_POST[‘question_id’]) < 300) {
dwqa_add_notice( __( 'Question is empty', 'dwqa' ), 'error' );

no sucess!

aleckzer
replied 8 years ago

Solved for maximum char in title:

}

if ( strlen($_POST[‘question-title’]) > 70) {
dwqa_add_notice( __( ‘Escreva menos aqui seu burro.’, ‘dwqa’ ), ‘error’ );
return false;
}

aleckzer
replied 8 years ago

When I tryed to post with empty question field using your plugin by defaulf. I could… so this
if ( empty( $_POST[‘question_id’] ) ) {
dwqa_add_notice( __( ‘Question is empty’, ‘dwqa’ ), ‘error’ );
is not working!!

aleckzer
replied 8 years ago

Also tryed:
if ( empty( $_POST[‘question-content’] ) ) {
dwqa_add_notice( __( ‘Question is empty’, ‘dwqa’ ), ‘error’ );

1 Answers
aleckzer
answered 8 years ago

Done.

In Handle.php line 364 find:  if ( isset( $_POST[‘_wpnonce’] ) && wp_verify_nonce( esc_html( $_POST[‘_wpnonce’] ), ‘_dwqa_submit_question’ ) ) {

Change it to:
if ( isset( $_POST[‘_wpnonce’] ) && wp_verify_nonce( esc_html( $_POST[‘_wpnonce’] ), ‘_dwqa_submit_question’ ) ) {
if ( $valid_captcha ) {
if ( strlen($_POST[‘question-title’]) < 30) {
dwqa_add_notice( __( ‘You must enter more then 30 charc title.’, ‘dwqa’ ), ‘error’ );
return false;
}
if ( strlen($_POST[‘question-title’]) > 70) {
dwqa_add_notice( __( ‘You must enter less then 70 charc title.’, ‘dwqa’ ), ‘error’ );
return false;
}
if (empty( $_POST[‘question-content’] ) ) {
dwqa_add_notice( __( ’empty question’, ‘dwqa’ ), ‘error’ );
return false;
}
if (strlen( $_POST[‘question-content’]) < 300) {
dwqa_add_notice( __( ‘question less then 300 charc’, ‘dwqa’ ), ‘error’ );
return false;
Thanks for myself!
Now please check about this:
https://www.designwall.com/question/wheres-friendly-register-page/

Powered by DW Question & Answer Pro