Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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: http://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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Hi, thanks for the idea. I ended up hooking 'comment_form_before' and 'comment_form_after' altogether. And I used ob_start("hook_callback"); in 'before', and ob_end_flush() in 'after'. I then have a callback function to do whatever I want with the form. –  He Shiming Jan 31 '13 at 11:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.