Prevent Page/Post From Being Created based on Pages/Posts per User per Time Unit

You will need to interrupt the post submission process much sooner. Your code hooked to admin_init stands a pretty good chance of working, with a modification or two, and wp_die is pretty harsh. I’d just redirect back to the originating page without saving, if it were me. Something like (untested)… function check_post_limit() { if (!isset($_POST[‘ID’])) … Read more

save_post action not firing when save

You have some errors in your code. For example, you unset a not defined variable. Some lines bellow you try to use again a not defined variable….maybe this is what is causing the problems. Can you try this? (Edited, I think is better get_posts than new WP_Query in this case) function wpse_update_postmeta($post_id) { if (defined(‘DOING_AUTOSAVE’) … Read more

How to change the post author when the post is published?

From the code you have posted there, it doesn’t look like, at any time, you’re are hooking the function on to save_post outside of your function. function change_pos_auth($post_id){ if ( ! wp_is_post_revision( $post_id ) ){ // unhook this function so it doesn’t loop infinitely remove_action(‘save_post’,’change_pos_auth’); if ( isset($_GET[‘auth_id’]) ) { $args = array(‘ID’=>$post_id,’post_author’=>$_GET[‘auth_id’]); // update … Read more