Support » Plugins » remove certain words before submitting comment

  • Hello friends, I have a problem. Does anyone know how to call a function each time a comment is posted? I need to verify that the comment text there are certain words and only then send the comment to the database.

    I tried this using a

    add_filter (‘comment_text’, array (‘Moderate’, ‘moderarComentarios’));

    But it only removes the words before displaying, I want something so I can remove it before you write to the database.

    this is my function:

    <?php
    
    function moderarComentarios($comment){
    
    $pattern = '/love|test/i';
    
    if(preg_match_all($pattern, $comment, $matches)){
    
    foreach ($matches as $matche) {
    $test = str_replace($matche, '***', $comment);
    }
    
    return $comment;
    }}
  • The topic ‘remove certain words before submitting comment’ is closed to new replies.