I will suggest to check the $post object in PHP before adding meta box.
And add the meta box if status is draft or auto-draft.
Consider this code
function update_meta_boxes($current_post_type, $post) {
$post_types = apply_filters('lsw_default_post_types', LSW_Organize_Drafts::$post_types);
remove_meta_box( 'tagsdiv-lswdrafttype', $post_types, 'side' );
if (isset($post->post_status) && ($post->post_status == 'draft' || $post->post_status == 'auto-draft')) {
add_meta_box('lswdrafttype_custom', __('Draft Type', 'lsw_organize_drafts'), array('LSW_Organize_Drafts','render_meta_box'), $post_types, 'side', 'core');
}
}
add_action( 'add_meta_boxes', 'update_meta_boxes', 10, 2);
Related Posts:
- How to add meta box to plugin admin page?
- Add custom meta box on Post page
- Validation Function for URL in plugin
- Creating Custom Meta Boxes on Plugin Option Page
- How to attach Links into page/post or custom post type?
- Add custom buttons with custom actions in Edit Post screen in WordPress?
- Plugin “Meta Box”: Implementing meta boxes in custom post type
- How WordPress autosave can save plugin fields?
- How can I filter the contents of a metafield before it’s displayed in the admin?
- Admin Dashboard with Custom Tab for Client
- Security checking in meta_box save is reluctant?
- Advanced Custom Fields
- RW Meta Box ,Problem setting post title
- dynamically generating plugin syntax
- Not able to complete meta box save function and sanitization/validation
- Correct way to make meta box with more than one meta field secure
- get_post_type on post.php
- All of my custom posttypes are 404’ing
- Save / Show multi line text in metabox
- PHP basics help in WP context – remove a class/function?
- How to remove plugin metaboxes from edit.php
- How can I make my metabox appear?
- How to inform the user that the save was not successful?
- Show meta box only when post is being published first time
- Retrieving Meta from Image Attachment
- WordPress metaboxes – textfield suggestion automatically populated
- Why are my queries interfering with the global post variable?
- Finding the screen id of a page generated with add_menu_page
- Date format – Meta Box plugin
- Meta Box by Rilwis, Load metabox on all page templates EXCEPT the homepage
- Adding custom meta boxes to specified custom post type
- Access post title from custom meta box on title change
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- add_meta_box creating default form field types
- Should meta boxes for specific pages be save in their own plugins?
- WordPress meta-box and checkbox-list
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- Custom Meta box change size
- Preset custom fields
- submit two file input fields in the same form
- WordPress default post categories meta box widget
- How to get checkbox by default true in metabox?
- How to pass multiple custom fields as shortcode’s parameters
- CMB2 Output Select Box Chosen Option
- Add Cancel Button to a Custom Meta Box
- WordPress CPT Url metabox collection
- Add_Meta_box to custom page (formidable edit post)
- why my wordpress dont have toolbar like, plugin, themes and other?
- My own metabox checkbox plugin only saves the last value I’ve checked
- CMB2 Post Search Field displays/repeats initial post if left empty
- Do something with thumbnail image on post publish
- How can I remove this sidebar from my Search Results page?
- Add custom field for users
- Alter add_meta_box
- Displaying image from a repeatable group
- How to add jquery to my custom post type wp plugin
- How to get rid of error message of custom metabox in dashboard when moving out of edit page?
- Metabox Data not saving
- Custom plugin breaks css.php on Multisite
- Advanced Custom Field User Help URL
- Problem for recover and save metaboxes
- How can i do custom author list?
- Meta Box plugin image_advanced not showing up on frontend
- How to change data format in custom meta box field [closed]
- iframe not showing on frontend when using a CMB2 field
- Problems with file_exists() with metabox plugin in WordPress
- Meta box not displaying on the plugin page
- add_meta_box showing blank screen in my page
- Twillio How To Send SMS for Custom Post Type
- Change the name of an installed plugin
- WP deregister, register and enqueue dequeue
- Hosting plugin Google Code with auto update?
- Website dumps encoded result
- why shouldn’t i save metadata when its a revision
- wordpress.org codebase
- Function to prevent users from trashing comments
- WordPress takes too much time (100 seconds) to load – Front end and back end
- how to change the verification url of pie register plugin of wordpress?
- stack-overflow-like content ranking for wordpress?
- finding whether request is for post, and post id
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Masonry images not working
- WordPress Image uploads plugin needed [closed]
- Sidebar widget: Randomly select text from a given set
- redirected you too many times
- Create custom pages with a plugin
- WordPress as template engine
- Woocommerce Backend Search by Title and SKU
- How do I make sure that my plugin only runs on article detail pages?
- Remove specific administrator’s capability
- Different Layerslider by page id?
- use EDD Content Restriction for restricting php in template
- Insert Sponsor logo in custom own theme
- Same Title on two different post type with single custom taxonomy
- Admin access to WordPress site with installing plugin
- Beginner question: Accessing js script in plugin
- Why is my activator class adding the files/running the actions I add?
- Trying to Find the PHP File/Function that Handles a Specific Form Action URL
- Newspaper theme, custom query vars, & custom rewrite rules
- How do I resolve “Some required plugins are missing or inactive”?