Need help refining added code in functions.php
-
Hey all,
I need an extra set of eyes to help me fix code that automatically sets any post to private so only the admin can publish any post draft.
The problem I’m running into is that every time a user clicks on the “All Posts”, coming from anywhere in the dashboard, an “auto draft” post is created.
Here is the code in question (found online & modified for admin only posting):
//Force posts of custom type to be private //…but first make sure they are not 'trash' otherwise it is impossible to trash a post function force_type_private($post) { if (($post['post_type'] == 'post')&&(!current_user_can('administrator'))) { if ($post['post_status'] != 'trash') $post['post_status'] = 'private'; } return $post; } add_filter('wp_insert_post_data', 'force_type_private');
How can I stop this from adding drafts?
Per original code “first make sure they are not ‘trash’ otherwise it is impossible to trash a post”.
I’m not 100% sure but I think it may be causing a problem?
Any ideas are welcome.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Need help refining added code in functions.php’ is closed to new replies.