Skip to content

Instantly share code, notes, and snippets.

@sergeliatko
Last active July 6, 2019 12:55
Show Gist options
  • Save sergeliatko/fda78b5316b34ad279a98245136df0f1 to your computer and use it in GitHub Desktop.
Save sergeliatko/fda78b5316b34ad279a98245136df0f1 to your computer and use it in GitHub Desktop.
Moves the Google reCAPTCHA notice after all fields before the submit button in WordPress comment form.
/**
* Move Google reCAPTCHA after the comment form fields and before the submit button.
*/
add_action( 'init', function () {
if (
has_action( 'comment_form_logged_in_after', 'gglcptch_commentform_display' )
|| has_action( 'comment_form_after_fields', 'gglcptch_commentform_display' )
) {
remove_action( 'comment_form_logged_in_after', 'gglcptch_commentform_display' );
remove_action( 'comment_form_after_fields', 'gglcptch_commentform_display' );
add_filter( 'comment_form_submit_field', function ( $submit_field ) {
ob_start();
gglcptch_commentform_display();
return ob_get_clean() . $submit_field;
}, 0, 1 );
}
}, 50, 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment