I was unable to find any action called wp_update_post. Are you sure it’s a valid one? Lets try the hook publish_post.
add_action('publish_post', 'check_user_publish', 10, 2);
function check_user_publish ($post_id, $post) {
$user_id = get_current_user_id();
if ($user_id != $post->post_author)
return;
$query = array(
'ID' => $post_id,
'post_status' => 'draft',
);
wp_update_post( $query, true );
}}
code not tested
Related Posts:
- Why doesn’t wp_update_post() update the post_status field?
- how to transition to custom post status on post save
- How to change post status from “draft” to “publish”?
- Auto draft posts when scheduled date is reached
- How to create posts with a specific date in bulk
- Is it possible to have more “levels” of draft/published statuses?
- wordpress function to change post status [duplicate]
- What is a “protected” post status?
- how to assign a status/mark to post?
- register_post_status and show_in_admin_all_list
- Changing post status in one click
- How can I run custom function when post status is changed?
- WP_Post_List_Table::get_views – Have post counts account for filters?
- Creating/editing custom ‘post-state’
- Using arbitrary post status without registering it
- Get a list of ALL Statuses both registered and built-in
- Adding custom post status to visibility in publish meta box
- change a post status when users update posts?
- Changing post status
- Change scheduled posts to published
- Include Drafts or Future posts with count_user_posts?
- Remove ‘private’ and ‘pending review’ options from post status dropdown
- Can not get future_to_publish to work
- How do I batch create revisions of all posts?
- Which is the better way to get the status of a post?
- Change sticky status of posts from phpMyAdmin
- “Publish immediately” with custom post status
- Modify Post Status Arguments
- Additional page and post status types
- Add a simple JS Alert Box on Post Submission
- Schedule future post to custom post status instead of publish?
- Why does get_post_status display published when attachment is in trash?
- Force Custom Post Type Status to ‘Future’ on first Save or Publish
- Workflow for attachments in WordPress
- How to update all posts but the current one (post__not_in not working?)
- How to change custom post type status when non-admin updates post?
- Custom post status filter links always show a count of all posts in the site with that status, not the logged in users count
- wordpress post status inquery
- Multiple Post Status
- Programmatically change post visibility on save_post action return a 500
- retrieve post details in loop
- Any way to change post/page status when editing page?
- transition_post_status doesn’t work with bulk updates
- Is there a before_save_post hook or something similar
- Submitted for Review back to a Draft page
- How to Add Custom Post Status in WordPress Admin
- Changing a post status name
- How to update post status to draft if user role is “pending’
- Set post status to draft after validating post meta values in save_post hook
- Implementing Soft Delete for Bulk Actions / Empty Trash
- How to update page status from publish to draft and draft to publish
- Connection lost. Saving has been disabled… (Updating Posts/Pages)
- How to change “Draft” string for status of custom post type to “Unavailable”?
- Automatically fill custom field value on post publish/update
- What are the limitations of wp_update_post()?
- Custom Post Status not showing in Custom Post Type ALL view
- Bulk Update of Custom Post Type Post Status through SQL
- What action is called when drafts are saved?
- Get images only if parent status is publish
- wp_update_post based function works on existing posts, but not new posts
- Create front end link to save post (or unpublish post) as draft
- Auto-generated posts not showing in backend (but being counted!)
- How to limit post of custom post status?
- Change name of existing post status type
- Can’t schedule post for another time
- Send email with custom fields after new draft is saved or new post published
- Update postmeta Parent when post_status child change
- Wrong post_status notice after wp_insert_post_data
- Individual post. Meta_key, taxonomy or post status for separation?
- Allowing user to edit posts based on the post status
- Removing all post statuses from a Custom Post Type
- wp_update_post not working
- Clear cache on post of one type when something happens to post of other type
- wp_update_post is not updating category
- How to display pending posts on the homepage only for editors
- Ajax function on #publish only saves as draft – how to make it publish?
- Odd behaviour for the update button when displaying a WP_List_Table
- Allow a subscriber to be an author and view only his post
- Trash Bin for Categories?
- How can I restore posts from ‘trash’ with their previous post_status? – WordPress
- How to hide private posts even if user is admin
- how to change value return by _stock_status
- recursively update content
- How to stop post status from reverting to Published?
- update flamingo_inbound post type after insert
- wp_insert_post() creates duplicates with ‘post_status’ => ‘publish’
- Modify loop to include all post statuses not just ‘published’
- Custom Post Status & Taxonomies
- How to change post status link order(priority) on cpt listing page
- Change custom post status to draft before today
- Get new (not old) post inside transition_post_status hook
- How to Show Different Information to your authors/contributers
- Enforce conditions only for draft posts using WyPiekacz, ignore pending and published posts
- Function is Missing an Action Hook
- Force Publish Future (Scheduled) Posts Immediately [duplicate]
- I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in publish
- hide woo commerce dashboard status and reports from woo commerce from specific users but display to other users
- transition_post_status hook, works – but not if the post is new
- How to Programmatically Trigger the Update of a Post in WordPress?
- retrieving external api data and updating existing custom post