I use WyPiekacz to set various conditions for authors when creating posts, for example checking if the post has a featured image or how many tags that are being used. It works fine.

However, these conditions are checked every time the post is submitted for review, updated or published. I want WyPiekacz to only check the conditions if the post is in Draft status. How can I do that?

The problem that I am experiencing currently is that for instance an editor changes the amount of tags and updates the pending post which then fails the tag rules set in WyPiekacz and thus the post gets changed back to draft status and the editor cannot access it again. Editors are only allowed to edit pending posts.

1 Answer 1


The check is invoked after a call to get_option( 'wypiekacz_allow_skip_rules' ).

When you filter pre_option_wypiekacz_allow_skip_rules and returns something different than FALSE, it should stop the check early. Not tested.


function wpse_100503_wypiekacz_for_drafts_only( $bool )
    if ( 'draft' === get_post_status( $GLOBALS['post'] ) )
        return $bool;

    return 0;

To prevent the post status reset, something like this could work:


function wpse_100503_wypiekacz_prevent_draft_reset( $errors, $text, $title, $post_data )
    if ( empty ( $errors ) )
        return $errors;

    if ( 'pending' === $post_data->post_status )
        remove_filter( 'query', array( $GLOBALS['wp_wypiekacz'], 'kill_sql_query' ) );

But, honestly, the plugin code is a mess.

  • Just tested this on a pending post, it did not work unfortunately. It changed back to draft status upon rule break. Any other ideas toscho?
    – Christine Cooper
    May 23, 2013 at 18:30
  • @ChristineCooper See my update. I am not sure if this works without side effects.
    – fuxia
    May 23, 2013 at 18:48
  • Didn't work I'm afraid. It displayed Fatal error: Cannot use object of type WP_Post as array in /functions.php on line 1627 on the post list page under the WyPiekacz Status column. Additionally, it stopped any other posts from displaying on the list. Strange!
    – Christine Cooper
    May 23, 2013 at 18:56
  • Then try $post_data->post_status in my second filter.
    – fuxia
    May 23, 2013 at 18:57
  • Where in the filter? Can you please update your answer.
    – Christine Cooper
    May 23, 2013 at 18:59

Your Answer

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

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