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?

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

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>

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, privacy policy and cookie policy

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