get_terms on save_post hook

You’re on the right track. When you do something like this in a form.. <input name=”tax_input[formats][]” /> You create levels in the $_POST array. So you’d get the formats array like this… <?php $formats = $_POST[‘tax_input’][‘formats’]; Full example… <?php add_action(‘save_post’, ‘wpse74017_save’); function wpse74017_save($post_id) { // check nonces and capabilities here. // use a ternary statement … Read more

Limit number of posts a user can make per minute?

I would begin with establishing the most friendly approach to this. I think it would be a warning after post Publish/Update button is clicked. It is possible to prevent the Edit Post screen loading if the user re-visits it within 2 minutes after the previous post is published. I don’t think that is practical though … Read more

Action on post publish

If your aim is to trigger code when a post is published, as in, the post_status of the post is set to publish, then you can hook into save_post like this: function cc_publish_wpse_263985( $postid ) { // check if post status is ‘publish’ if ( get_post_status( $postid ) == ‘publish’) ) { // do something … Read more

Prevent post from being published if no category selected

You can do this easily with jQuery: /* Checks if cat is selected when publish button is clicked */ jQuery( ‘#submitdiv’ ).on( ‘click’, ‘#publish’, function( e ) { var $checked = jQuery( ‘#category-all li input:checked’ ); //Checks if cat is selected if( $checked.length <= 0 ) { alert( “Please Select atleast one category” ); return … Read more

Is there a way to know if a post has been published through XML-RPC?

You could use a custom field for a post which is saved via XMLRPC by using the action hook xmlrpc_publish_post. wpse_from_xmlrpc() could than check this custom field. <?php add_action( ‘xmlrpc_publish_post’, ‘add_xmlrpc_postmeta’ ); function add_xmlrpc_postmeta( $post_id ){ update_post_meta( $post_id, ‘send-by-xmlrpc’, 1 ); } function wpse_from_xmlrpc( $post_id ){ $xmlrpc = get_post_meta( $post_id, ‘send-by-xmlrpc’, true ); if( $xmlrpc … Read more

Does WordPress remove draft status automatically?

Just by itself WordPress will not change the post status. However, if you have a plugin like Draft Scheduler installed, drafts will be published automatically, possibly with some interval. So, you should check your plugins on this type of activity. Another possibility would be that a backup of the database has been installed after a … Read more