Change the tag of the comment submit button

You should be able to change the HTML structure for the comment form’s submit, with the comment_form_defaults filter.

Here’s an untested example:

add_filter( 'comment_form_defaults', function( $defaults )
{
    // Edit this to your needs:
    $button = '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />';

    // Override the default submit button:
    $defaults['submit_button'] = $button;

    return $defaults;
} );

where you adjust the $button to your needs.

There’s also the comment_form_submit_button filter:

add_filter( 'comment_form_submit_button', function( $submit_button, $args )
{
    // Override the submit button HTML:
    $button = '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />';

    return sprintf(
        $button,
        esc_attr( $args['name_submit'] ),
        esc_attr( $args['id_submit'] ),
        esc_attr( $args['class_submit'] ),
        esc_attr( $args['label_submit'] )
     );

}, 10, 2 );

It should even be possible with the comment_form_submit_field filter, but it contains hidden fields as well, so it might not be as helpful as the other filters.

Leave a Comment