Force authors to Preview a post before publishing

I’m looking to find a way to force authors (including admin & editors) to preview their post before publishing. Is this possible, if so does anyone know the easiest way to achieve this?

I’m running WP3.5.1. Thanks

Related posts

1 comment

  1. This is completely untested but I think the concept is good, and good idea too though I’d have an angry mob with pitchforks to face.

    1. Set a marker for your post when the post is previewed. You can save
      it in either $wpdb->options or $wpdb->postmeta. I haven’t
      quite decided which would be better, and it probably depends on
      details of the implementation. (But probably $wpdb->postmeta).
    2. Check that marker before you allow a post to be published.

    So…

    function set_preview_marker_wpse_99671() {
      if (is_preview()) {
        // set the marker
      }
    }
    add_action('pre_get_posts','set_preview_marker_wpse_99671');
    

    Then check the key before you allow publishing.

    // code shamelessly stolen from another answer
    // http://wordpress.stackexchange.com/questions/96762/how-to-make-a-meta-box-field-a-requirement/96767#96767
    function req_meta_wpse_96762($data){
      $allow_pending = false;
      if (isset($_POST['meta'])) {
        foreach ($_POST['meta'] as $v) {
          if ('your_required_key' === $v['key'] && !empty($v['value'])) {
            $allow_pending = true;
          }
        }
      }
      if (false === $allow_pending) {
        $data['post_status'] = 'draft';
      }
      return $data;
    }
    add_action('wp_insert_post_data','req_meta_wpse_96762');
    

    You might want to unset that key when the post is published to force the preview check again if it is edited.

Comments are closed.