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