Asking for help with your code without at least indenting it properly, is like going to the dentist without brushing your teeth.
— Konstantin Kovshenin (@kovshenin) October 13, 2012
Here is what I had to look at this weekend, only about ten times longer.
add_action('save_post','my_save_post',10,2); function my_save_post($post_id,$post){ if(wp_is_post_revision($post_id)){return; } $post= get_post($post_id); if($post->post_parent==5){ $donotpublish=true; if($donotpublish){ remove_action('save_post','my_save_post'); wp_update_post(array('ID'=>$post_id,'post_status'=>'draft')); } } }
Yuck! So if you’re planning to ask for help with your code on forums, IRC, etc., please, do take some time to clean it up for the people that would love to help you. The WordPress Coding Standards is a good place to start.