The site constantly flies spam in the comments. I don’t know much about WP (I understand that everything should be done in function.php so that it doesn’t disappear after the update), so tell me how to add a hidden field for the comments form, but because spam doesn’t go directly to my site ( mailing is)
|
1 answer
You must use the comment_form_default_fields hook.
In functions.php child theme, add something like this:
add_filter( 'comment_form_default_fields', 'add_field' ); function add_field( $fields ){ $fields['my_hidden_field'] = '<p class="comment-form-my-hidden">' . '<label for="my-hidden">' . 'My hidden field' . '</label> ' . '<input id="my_hidden_field" name="my_hidden_field" type="hidden" value="" size="30" /></p>','; return $fields; } This will create an additional field in the form of comments, which you can then process yourself or analyze the comment using the pre_comment_approved filter.
add_filter( 'pre_comment_approved', 'filter_function_name_11', 10, 2 ); function filter_function_name_11( $approved, $commentdata ){ // проанализировать комментарий и // вернуть 0, 1 или 'spam' return $approved; } |
function.php, then not the VP, but the themes. Moreover, the subsidiary is SeVlad