Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oscar-Abad-Folgueira/8dc9a73400a961e1693e0c4152f16ad7 to your computer and use it in GitHub Desktop.
Save Oscar-Abad-Folgueira/8dc9a73400a961e1693e0c4152f16ad7 to your computer and use it in GitHub Desktop.
WordPress snippet: Establecer un mínimo de caracteres al comentar
<?php
/**
* @snippet WordPress snippet: Establecer un mínimo de caracteres al comentar
* @author Oscar Abad Folgueira
* @author_url https://www.oscarabadfolgueira.com
* @snippet_url https://www.oscarabadfolgueira.com/wordpress-snippet-establecer-un-minimo-de-caracteres-al-comentar/
*/
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