‘transition_post_status’ only fires when pressing “Add New”

This will do something when you publish a post in the backend. function my_publish( $post_id ) { if ( ( $_POST[‘post_status’] === ‘publish’ ) && ( $_POST[‘original_post_status’] != ‘publish’ ) ) { error_log(‘WordPress would be better if it did not use Google Fonts. Looking forward to the system fonts.’); } } add_action( ‘publish_yourCustomPostType’, ‘my_publish’, 10, … Read more

Frontend Post Form Validation

The best way to do form validation is with a combination of JavaScript and PHP. The reason why you want to perform JavaScript validation is to give the users a chance to correct their errors without submitting the form. Plus, it will stop any casual mistakes. You will also want to ensure validation on the … Read more

add filter to “quick edit menu” in wordpress admin

You do not want to reference the global $post, but the post that is given to you as one of the argument. You simply need to remove global $post; Remember also to sanitize input and prefix function names. function wpse50651_filter_transition_post_status( $new_status, $old_status, $post ) { global $wpdb; $wpdb->query( $wpdb->prepare( “UPDATE my_table SET post_status=%s WHERE post_id=%d”, … Read more