I’ve been handed over a design to translate into WordPress plugin & theme. My question is regarding building a custom comment form.

The design used some custom scripts on the comment submit button. It handles ‘submitting…’ button state, animations, and checks. And it uses an anchor tag <a> with jQuery’s .bind to submit the form.

I noticed that the comment_form function of WordPress did not offer a solution to change the submit button. I only needed to remove it as I’m handling it myself.

What made it worse is that WordPress has hard coded <input name="submit"> into the button, which made it impossible for jQuery to call .submit (more details on this issue here: https://stackoverflow.com/questions/12540953/property-submit-of-object-htmlformelement-is-not-a-function). So just hiding this button with CSS won’t work.

If I prefer not to use the <input type="submit"> button of WordPress comment form, do I have any options to build my own button?

Thanks.

1 Answer
1

This is hard. Output buffering could solve that:

add_action( 'comment_form_field_comment', 'ob_start' );
add_action( 'comment_form', 'wpse_83898_replace_submit' );

function wpse_83898_replace_submit() 
{
    $html = ob_get_clean();
    # do some magic
    echo $html;
}

Just an idea, not tested.

Leave a Reply

Your email address will not be published. Required fields are marked *