WP 4.4.1 allow empty comments via add_action ‘pre_comment_on_post’

)

first thanks a lot to @swisspidy and the suggestion to modify $_POST on the init hook.

but after a bit of more thinking and looking at the code i took a different approach.

instead of fixing things afterwards, after the form submit, i decided to fix things via jQuery during the form submit and do the necessary checks about the comment input field there.

as i already do form validation via the jquery validation plugin:

http://jqueryvalidation.org/

and it does provide a custom submit handler

http://jqueryvalidation.org/documentation/

i decided to fix things in the custom submitHandler and assign #comment a value if the other checkbox #addTimeSheet is checked and the #comment field is not filled in:

jQuery(document).ready(function() {jQuery("#commentform").validate({

   submitHandler: function(form) {
    // do other things for a valid form

        if(jQuery("#addTimeSheet").is(":checked") == true) {

            if(jQuery("#comment").val() == "") {


                jQuery("#comment").val("%comment-dummy%");

            }

        }          

    form.submit();
  }

,

this way i don’t need to fix things afterwards and i think it is a more elegant solution 😉

anyway, thanks again for your help & wish you all the best

greetings
becki