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.

Jetpack Subscription Checkboxes

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. See the screenshot.

Jetpack Subscription Checkboxes Above Post Comment Button
Jetpack Subscription Checkboxes Above Post Comment Button

Share This Article

Subscribe Membership Plan ($9.99/mo)

  • Get full access to all premium tutorials
  • Get Support for the posted content
  • Request for specific how-to tutorials
  • Cancel the subscription at anytime

Reader Interactions

20 Discussion to This Post

  1. I always your short and clear tutorial. But I need little more help.
    How to auto check both checkboxes?

  2. Hi,

    I know it’s an old post but I find it quite useful.
    I have an issue that’s probably related to my theme, but maybe you can help. Your code worked perfectly to put checkboxes above the button, but the text moves to a new line. So I have a checkbox and the text that follows it is in a new line and not next to the checkbox.

    Can you please help?

    • Can you share the site URL?

      I’m guessing that this CSS can work

  3. Thank you very much! My Theme wasn’t showing for whatever reasons the “subscribe to upcoming posts” part (the the other one), but your script does it show. This really helped me a lot! Thanks

  4. Hello, and thank you for this tutorial.

    I would like to put the checkboxes under the last field (url) of my form, and I have change the $fields in my comments.php, can you explain how to do this ?

    Thank !

    • Are you added the above code? If you follow my steps and add the code in your functions.php file then it will add the checkboxes above the submit button.

      • Hello and thanks for your answer.

        If I add your code to the functions.php, the checkbox go under the textarea, and not between the last field (url) and the submit button, as you can see in the picture :
        http://espace.sythin.net/wp-content/uploads/checkboxes.png

        I have tried to change the line 26 ($defaults[‘comment_field’] = $defaults[‘comment_field’] . $str;) but I haven’t find what to write instead.

        • Replace this line ($defaults[‘comment_field’] = $defaults[‘comment_field’] . $str;) With following code:

              if( is_user_logged_in() )
                $defaults['comment_field'] = $defaults['comment_field'] . $str;
              else
                $defaults['url'] = $defaults['url'] . $str;
          
            • Completely remove this

              if( is_user_logged_in() )
                $defaults['comment_field'] = $defaults['comment_field'] . $str;
              else
                $defaults['url'] = $defaults['url'] . $str;
              

              And add this line

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

              Hope it will work.

    • Add this line:

      $blog_checked = $comments_checked = 'checked';

      Below this line :

      $str= '';
      • I use genesis framework. I added $blog_checked = $comments_checked = ‘checked’; below $str= ”; in functions.php on childtheme. It is not working. Any other suggestion?

      • Yeah.. I removed $comments_checked = ”;
        $blog_checked = ”;. Now it is working.

  5. This didn’t work for me.

    It would remove the checkboxes fine, but would not add them back in.

    I ended up using a little bit of CSS instead.

    Thought I’d leave it here, in case someone else has the same problem.

    .commentsBox .comment-form p.form-submit {
    position: relative;
    top: 120px;
    }

    .commentsBox .comment-form .comment-subscription-form {
    position:relative;
    top: -80px;
    }

    • Hi Paul

      My PHP Code is 100% working perfectly. I added the code in my functions.php file. For live preview check my comment form. Two checkboxes are coming above the submit button now.

      I am sure that you did something wrong at your end. For that reason it was not working at your end.

      Best
      Chinmoy

Leave A Reply

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