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
- How to avoid infinite loop in save_post callback
- Turn Off Automatic Trash Deletion?
- Let private posts stay in status “private” after edit through “editors”
- Post/Page Publish/Update button not clickable once I make an edit
- Custom post status and preview
- get_terms(); show private posts when logged in
- Scheduling posts to update once per day with wp_cron
- featuring old articles without messing up with the archive
- Show scheduled posts in archive page
- How do I limit the status options for bulk/quick edit to only Published and Draft?
- bulk post_content update
- Mass Update lines of code for all posts
- Enable commenting on front-end preview page for pending posts
- Error after deleting Custom Post Type with a function (no trash used)
- Automatically remove a canceled order in Woocommerce
- wp_insert_post_data filter hook identify current action
- custom post scheduler for drafts
- Add new post with predefined / preset date
- Template redirect template loaded, but the header 404
- how to get last revision id created after wp_update_post
- Custom date changer post_date => future – missed schedule error
- Second transition_post_status hook fired instead of the first
- How to get the Tags on Publish post hook?
- How to define which register_post_status goes to which register_post_type?
- 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
- How to update the children of a post?
- 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
- Bulk post approval and publishing doesn’t work