Created
May 9, 2020 18:24
-
-
Save Oscar-Abad-Folgueira/8dc9a73400a961e1693e0c4152f16ad7 to your computer and use it in GitHub Desktop.
WordPress snippet: Establecer un mínimo de caracteres al comentar
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 | |
/** | |
* @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