Changing post status with pre_post_update hook
-
I’m trying to conditionally change the post status with this code:
// if contributor edits published post, change the status to pending function contributor_status_to_pending($post_id) { $post = get_post($post_id); if ($post->post_status == 'publish') { $post->post_status = 'pending'; } } if ( current_user_can('contributor') ) add_action('pre_post_update','contributor_status_to_pending');
Through debugging, I can see that the function fires for a contributor, that execution gets inside the if, and that $post->post_status is set to ‘pending’.
But the post remains ‘publish’.
Any help would be appreciated
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Changing post status with pre_post_update hook’ is closed to new replies.