Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cptr_save() {
- global $post_ID;
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
- if (!isset($_POST['myplugin_noncename'])) return;
- if (!wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__))) return;
- if (!current_user_can( 'edit_post', $post_ID ) ) return;
- $id = $_POST['post_ID'];
- $related = isset($_POST['reladded']) ? $_POST['reladded'] : array();
- update_post_meta($id, CI_CPTR_POST_RELATED, $related);
- // this is where I attempt to update the post_type
- $related_meta = get_post_meta($id, CI_CPTR_POST_RELATED, true);
- $related_posts = array();
- if (!empty($related_meta)) {
- //Get a list of post IDs
- foreach ($related_meta as $myrelated) {
- $post = get_post($myrelated);
- $related_posts[] = $post;
- }
- if(count($related_posts)>0)
- {
- foreach ($related_posts as $post)
- {
- // Update post
- $my_post = array( 'id' => $post->ID, 'post_status' => 'publish');
- // Update the post into the database
- wp_update_post( $my_post );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement