Set page to draft on plugin deactivation

I’m posting this as another solution for you and its based on the page id /* $post_id – The ID of the post you’d like to change. $status – The post status publish|pending|draft|private|static|object|attachment|inherit|future|trash. */ function change_post_status($post_id,$status){ $current_post = get_post( $post_id, ‘ARRAY_A’ ); $current_post[‘post_status’] = $status; return wp_update_post($current_post); } So once you have this function you … Read more

How to list “invisible” Auto Drafts?

try pasting this in your theme’s functions.php file add_filter( ‘parse_query’, ‘display_autosave_and_revisions’ ); function display_autosave_and_revisions( $query ) { global $pagenow,$typenow; if ( is_admin() && $pagenow == ‘edit.php’ && $typenow == “post”) { $query->query_vars[‘post_type’] = array(‘revision’,’post’); $query->query_vars[‘post_status’] = ‘any’; } }

Preview page/post revisions without overwriting current content

WordPress has built in Revision Management. You can set the saved revisions to a custom number in the wp-config.php file in your installation. define( ‘WP_POST_REVISIONS’, 30 ); NOTE: You should be aware of the »autosave« mechanism, which also sets post revisions. So leaving a tab open for 1 hour with a Post Revision interval of … Read more

How to show or hide a post based on meta_value selection?

Use the pre_get_posts action to alter the main query with meta_query arguments to only select posts with active current_status. This example would work for your main posts page. See Conditional Tags for how to determine when other types of queries are run. function wpa_current_status( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $meta_query … Read more

Edit draft from other author

Please review the information here: http://codex.wordpress.org/Roles_and_Capabilities Specifically, the following: Editor – somebody who can publish and manage posts including the posts of other users. An Editor is exactly that – someone who can edit what other people are doing. Ensure that the Users who you want to have Editor rights are assigned as Editors in … Read more

wp_insert_post Only creates draft

The reason why your code created drafts only is status=”pending” make it publish Like // Prepare to save! do_action( ‘wpo_frontend_before_save_order’, $order_details, $user_details ); $post = array( ‘post_title’ => $order_details[‘title’], ‘post_author’ => get_current_user_id(), ‘post_type’ => ‘wp_order’, ‘post_status’ => ‘publish’ ); $postID = wp_insert_post( $post ); if ( is_wp_error( $postID ) ) { set_transient( ‘wpo_new_order_message_’ . get_current_user_id(), … Read more