How to make custom comment fields required and message field not required

Here is a related question that should answer yours. Basicly you want to use the pre_comment_on_post hook

    function custom_validate_comment() {
    //validate for brief and rating
if( empty( $_POST['brief']) || empty( $_POST['rating'])  )
        wp_die( __('Error: you must fill in both the rating and the brief') );
//make comment not required
if(empy($_POST['comment']){$_POST['comment'] == "empty_comment";}
}

add_action('pre_comment_on_post', 'custom_validate_comment');

function custom_change_comment( $commentdata ) {
    if( $commentdata['comment'] == 'empty_comment' )
        $commentdata['comment'] = '';
    return $commentdata;
}

add_filter('preprocess_comment', 'custom_change_comment');

That should at least get you on the right track

Leave a Comment