Force logged in users to provide more data when commenting

One idea could be to save all your additional data on as user meta, which would allow you to retrieve it when a comment is posted by a logged in user and store a copy of it along side the comment as you would for non-logged in users. Naturally this depends on the kind of data, and the extent to which it has to be unique for each comment.

An alternative approach might be to hook into the comment_form_top action, which is called by comment_template() before printing the comment form. Assuming that you have added the additional fields using the comment_form_default_fields filter, you would then just do something like this:

function get_extra_fields() {
    return array('age' => '<p class="comment-form-age"><label for="age">' . __( 'Age' ) . '</label>' .
        '<input id="age" name="age" type="text" size="30"' . '' . ' /></p>');
}

function add_comment_fields($fields) {

    $fields = array_merge($fields, get_extra_fields());

    return $fields;
}
add_filter('comment_form_default_fields','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);


function add_comment_fields_logged_in() {
    if (!is_user_logged_in())
        return;

    $fields = get_extra_fields();

    foreach ( $fields as $name => $field ) {
        echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
    }
}
add_filter('comment_form_logged_in_after', 'add_comment_fields_logged_in');

Possibly you will also need to do some checking to verify that all required data has been submitted by the form etc., but that will likely apply for non-logged in users as well.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)