Changing status of Published posts which have less Content to “Draft”

function draftpost(){
    global $wpdb;
    $prefix = $wpdb->prefix;
    $wpdb->query("UPDATE ".$prefix."posts SET post_status='draft' WHERE LENGTH( post_content ) <500");
}
add_action('publish_post', 'draftpost');

This code is working Fine for changing Published Items to Draft.

Issue is that this code removes my Custom Menu and make all Items in Menu to PENDING.
How can I solve this?

Related posts

Leave a Reply