Support

Account

Home Forums General Issues Custom comment field, not to display on reply Reply To: Custom comment field, not to display on reply

  • This will remove the field if the person has already made any comment on the current post.

    
    add_filter('acf/prepare_field/name=YOUR_FIELS_NAME', 'remove_if_previous_comments');
    function remove_if_previous_comments($field) {
      if (!is_user_logged_in()) {
        return $field;
      }
      global $post;
      $user = get_current_user_id();
      $args = array(
        'author__in' => array($user),
        'post_id' => $post->ID,
        'count' => true
      );
      $count = get_comments($args);
      if ($count) {
        $field = false;
      }
      return $field;
    }
    

    unfortunately you cannot remove the field depending on if the comment is a reply to another comment or not. WP only has one comment form and it’s just moved around when replying to other comments.