Customizing Comments Meta

I am trying to add some custom comment meta fields and when using roots this wont work. The code:

<?php
function add_comment_fields( $fields ) {

        ?>

        <p class="comment-form-age">
                <label for="age"><?php _e( 'Age' ); ?></label>
                <input id="age" name="age" type="text" size="30" />
        </p>

   <?php
}
add_filter( 'comment_form_logged_in_after', 'add_comment_fields' );

function add_comment_meta_values($comment_id) {
 
    if(isset($_POST['age'])) {
        $age = wp_filter_nohtml_kses($_POST['age']);
        add_comment_meta($comment_id, 'age', $age, false);
    }
 
}
add_action ('comment_post', 'add_comment_meta_values', 1);
?>

Functions in other themes, but not roots. Why is this? What do I need to do different?

Don’t use the filter and manually add the field to templates/comments.php instead.

Can you elaborate or point to documentation?
When I duplicate a field in the templates/comments.php nothing in the duplicated field is submitted or persists.

You still need the second function and action to record the meta. If you’ve added a custom field inside the form and it’s not posting, then you’ll have to debug the problem with your HTML.