Move Two Jetpack Subscription Checkboxes to Above “Post” Button

Jetpack is a popular wordpress plugin and lot of wordpress users are using this plugin. This plugin have a module “Jetpack Subscription” and this module is adding two checkboxes into comment form. Jetpack is not providing any extra settings for repositioning this two checkboxes. Using CSS we can move the “Post Comment” button below the checkboxes. But as a PHP programmer how you can do this by PHP script? This article will provide the code.

First Removing the checkboxes

By Filter

add_filter('jetpack_comment_subscription_form', 'gd_jp_comment_subscription_form');
function gd_jp_comment_subscription_form($str){
  return '';
}

OR

By Hook

add_action( 'get_header', 'gd_remove_jp_subscriptions_boxes' );
function gd_remove_jp_subscriptions_boxes() {
    if (class_exists('Jetpack_Subscriptions'))
       remove_action( 'comment_form', array( Jetpack_Subscriptions::init(), 'comment_subscribe_init' ) );
}

Second adding the two checkboxes above the Submit button

Add the following code in functions.php file

//* Remove comment form allowed tags
add_filter( 'comment_form_defaults', 'gd_remove_comment_form_allowed_tags' );
function gd_remove_comment_form_allowed_tags( $defaults ) {
global $post;

$defaults['comment_notes_after'] = '';

if (class_exists('Jetpack_Subscriptions')) {
$str = '';
$comments_checked = '';
$blog_checked = '';

if ( FALSE === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 == get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) ) {
// Subscribe to comments checkbox
$str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_comments" id="subscribe_comments" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $comments_checked . ' /> ';
$str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . __( 'Notify me of follow-up comments by email.', 'jetpack' ) . '</label>';
$str .= '</p>';
}

if ( 1 == get_option( 'stb_enabled', 1 ) ) {
// Subscribe to blog checkbox
$str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_blog" id="subscribe_blog" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $blog_checked . ' /> ';
$str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . __( 'Notify me of new posts by email.', 'jetpack' ) . '</label>';
$str .= '</p>';
}

$defaults['submit_field'] = $str . $defaults['submit_field'] ;
}

return $defaults;
}

Now refresh your single post details page and you’ll get this.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.