Created
February 27, 2016 14:16
-
-
Save OscarAbadFolgueira/a49a0321b32a379d0a8c to your computer and use it in GitHub Desktop.
WordPress Snippet to set the minimum length for comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This WordPress / Woocommerce code snippet set the minimum length for comments. | |
* | |
* Author: Oscar Abad Folgueira | |
* Author URI: http://www.oscarabadfolgueira.com | |
* | |
* You can copy this snippet and paste in your functions.php or you can build your own plugin | |
* | |
* Change the number of characters to your needs. | |
*/ | |
add_filter( 'preprocess_comment', 'set_minimal_length_for_comments' ); | |
function set_minimal_length_for_comments( $comment ) { | |
$min_length = 15; | |
if ( strlen( $comment['comment_content'] ) < $min_length ){ | |
wp_die( 'Los comentarios deben ser por lo menos de ' . $min_length . ' caracteres.' ); | |
} | |
return $comment; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment