I wonder if you could use something as simple as this: (similar to the suggestion of @ialocin)
/**
* Use the "Force" on the post status ;-)
*/
add_action( 'wp_insert_post_data', function( $data, $postarr ){
$change_post_status = array( 'draft', 'private' ); // Edit to your needs
if( 'cpt' === $data['post_type']
&& in_array( $data['post_status'], $change_post_status, TRUE )
)
$data['post_status'] = 'publish';
return $data;
}, PHP_MAX_INT, 2 );
where we just force the post status value when it’s part of the $change_post_status
array – before the post is saved.
(… or maybe I’m misunderstanding the setup 😉
Related Posts:
- New post status for custom post type
- How to change “Draft” string for status of custom post type to “Unavailable”?
- Custom post status and preview
- Custom Post Status not showing in Custom Post Type ALL view
- Setting a title on a Custom Post Type that doesn’t support titles
- delete custom post based on custom field date
- How do I check if a posts status is set to draft or pending?
- Error after deleting Custom Post Type with a function (no trash used)
- How to set default status to custom post type
- 1 day after custom date change post status to draft
- Auto-generated posts not showing in backend (but being counted!)
- How to limit post of custom post status?
- Custom date changer post_date => future – missed schedule error
- Featured image overlay when changing post status
- Custom post type suppress transition from future to publish
- Update postmeta Parent when post_status child change
- Removing all post statuses from a Custom Post Type
- Add custom post type drafts to RSS feed
- How to define which register_post_status goes to which register_post_type?
- Programmatically change post visibility on save_post action return a 500
- Published post auto change status to pending after 90 days
- Manually adding or updating CPT automatically sets post_status of future
- Change user role when user’s first post gets published
- Set Post Private if no linked Post Objects (ACF)
- Show custom post status when logged out
- How to hide private posts even if user is admin
- Update post status from “publish” to “trash” prior to year 2018
- edit.php all post not working
- Sql Update CPT from publish to draft and particular custom field
- Custom Post Status not getting displayed after post update
- Custom status and permalinks don’t work?
- How to save post_status using action save_post?
- How to stop post status from reverting to Published?
- wp_insert_post() creates duplicates with ‘post_status’ => ‘publish’
- Implement post status update as frontend news announcement
- date archive future posts
- Custom Post Status & Taxonomies
- How to change post status link order(priority) on cpt listing page
- Comments not working (error not allowed) on posts with custom post status
- Get custom post_type’s archive URL
- Hook for post and page load
- How to create a custom template for a custom taxonomy?
- Custom post types filtered by taxonomy using REST API v2
- Changing the URL Structure of a Paginated Custom Post
- Display text if current user has written 1 or more posts in a custom post type
- Pull Two Posts Into Custom Post Type `single-cpt.php`
- Compare 3 custom fields and sort by oldest
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- WordPress custom post type Single.php?
- how to use two permalinks for one custom post type
- Adding capabilities to default roles
- Filters post in admin with dropdown select, custom post type
- Custom Permalink Tag breaks Pagination
- Display posts if a custom field value is equal to another custom field value
- Custom Fields vs Separate Table
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- Using several custom fields as custom post title
- Return the thumbnail meta data for getter and setter
- How to create Blog Post Specific Widget
- Custom Post-Type not in admin menu
- Page vs Custom Post Types Differences/Issues
- Roles for Custom Post Types
- Having unique constraints for custom fields in a custom post type
- JS innerhtml changing style when using AJAX
- How do I add a custom screen for a custom post type to be called from custom post row action?
- Add Custom Post type menu to another menu in specific location
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- How to get custom posts sub category link
- Pretty URLs and custom post types
- Limit Search to Post Type With Apostrophe return search not found
- Add a custom text to admin footer in a Custom Post Type page
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- List of users that clicked a ‘Join’ button at single post
- search custom post type by custom fields on front end
- category list with cutom post count
- Run shortcode in custom script in wp_head if post type is CPT ‘Jobs’
- get_delete_post_link() only works for administrator, even if other user has exactly the same permissions
- Add Class according to the order of appearance
- How to know which archive page is active
- Custom Post Type UI
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- Custom wp-query display post only today
- How to filter custom post type by multiple Taxonomies
- Order custom post type by taxonomy
- Display Custom Post Type Based on Taxonomy With WP_Query()
- Cannot display the_content() after removed WordPress 5’s auto embed feature (iframe & blockquote)
- Problem in moving cpt’s from local website to live website
- Permalink for custom post type pages not working
- Update Cateogory Taxonomy Count for Attachment Post Type
- Child Theme problems
- Calling specific page with wp query
- Trying to modify custom search function in plugin to search postmeta table for keyword as well as posts table
- Connecting multiple post types? Or linking “News” posts with “Game” posts how?
- Querying multiple taxonomies in URL leads to wrong taxonomy archive
- Unable to sort wp_query by date/time with multiple meta_key s
- Exposing custom fields to the user in custom type post
- How to add custom settings to the menu of custom post types?
- Custom post type split title, setup permalink accordingly
- Admin menu link with variable