Minimum Length review

This topic contains 10 replies, has 3 voices, and was last updated by  giacomo 9 years, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #44199

    giacomo
    Expired Member
    Post count: 235

    Hi all,

    i would like to have reviews of a MINIMUM (not max) length of 180 characters.

    Anyone knows a plugin that can help me?

    Maurizio S.

    #44204

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    the only plugin I ever heard about for this is https://wordpress.org/plugins/minimum-comment-length/ from Yoast.

    However it appears to be working only with the default wordpress comment function is used, if you use a walker function like we do, apparently it doesn’t work.

    Personally I haven’t tested it.

    Let us know how you went,

    Thanks

    #44205

    Simone
    Expired Member
    Post count: 3515

    Ciao,
    add the following code to your functions.php inside your child theme’s folder

    
    
    add_filter( 'preprocess_comment', 'commentominimo' );
       
     function commentominimo( $commentdata ) {
          $commentominimo = 180;
       
          if ( strlen( trim( $commentdata['comment_content'] ) ) < $commentominimo ){
          wp_die( 'La recensione deve avere un minimo di ' . $commentominimo . ' caratteri.' );
          }
      
          return $commentdata;
          }
    #44207

    Paolo
    Site Admin
    Post count: 31206

    Simone was way better than me on this one… 🙂

    #44208

    giacomo
    Expired Member
    Post count: 235

    Thanks
    a lot 😀

    #44335

    giacomo
    Expired Member
    Post count: 235

    Update:

    I’ve tried this code but unfortunately it doesn’t work… can you suggest something else?

    thanks

    #44336

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    Simone said he tested it and it was working for him, are you sure you are adding it correctly?

    Let us know,

    Thx

    #44339

    Simone
    Expired Member
    Post count: 3515

    It is a tested code, so if you’re pasting it in the right way (in the functions.php, inside your child theme’s folder), it must work 🙂

    You can test it here
    http://test.simonetambasco.com/gd/annunci/italy/calabria/catanzaro/device

    #45888

    giacomo
    Expired Member
    Post count: 235

    OK IT WORK PERFECTLY! thanks a lot.

    i would like to redirect the user back to the listing page with two options:
    1- after a couple of seconds he is automatically redirected
    2- with a “back” button

    i modified the working php code but it seems not to work…

    
    
    add_filter( 'preprocess_comment', 'commentominimo' );
       
     function commentominimo( $commentdata ) {
          $commentominimo = 180;
       
          if ( strlen( trim( $commentdata['comment_content'] ) ) < $commentominimo ){
          wp_die( 'La recensione deve avere un minimo di ' . $commentominimo . ' caratteri.' );
          
          header("Location: {$_SERVER['HTTP_REFERER']}");
          exit;
          }
         return $commentdata;
    
          }
    
    

    Thanks

    #45901

    Simone
    Expired Member
    Post count: 3515

    Hi, im not sure the page sends a referrer, thats why it isn’t working. You can try with a back button, as explained here
    http://www.w3schools.com/jsref/met_his_back.asp

    #45908

    giacomo
    Expired Member
    Post count: 235

    ok thanks

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount