Here I am changing status of my Published posts to draft where post have less content using following code
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?
You need to extend your query.
Your query overwrites all post_types, including nav_menu_item.