2

I'm building post to email plugin and I need to add a checkbox to the publish post widget like this one:

enter image description here

My idea is to add a checkbox that says "Send this by email", and get that info inside the publish_post listener:

add_action('publish_post', function($post_id) {
     // Was the checkbox checked?
}

How can this be done?

1
  • What's the exact question? Have you inspected $_POST inside the callback?
    – kaiser
    Sep 12, 2014 at 21:01

1 Answer 1

3

Hook into post_submitbox_misc_actions and print the checkbox:

add_action( 'post_submitbox_misc_actions', function() {
    ?>
<div class="misc-pub-section">
    <label><input type="checkbox"> click me</label>
</div>
    <?php
});

Wrap the code in a <div class="misc-pub-section">, otherwise the spacing looks a little bit weird.

Examples: language selector, noindex checkbox, public preview checkbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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