Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress Metabox saves on Update or Publish, but not on Saving Draft

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #32318
    rmlumley
    Member

    I have created custom post types that also have custom meta_boxes I’ve created. Currently, they save when I publish or update a post, but they don’t save when I’m in draft mode making changes.

        add_action('save_post', 'save_details');

    function save_details($post_id){
    global $post;
    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
    return $post_id;
    }
    if ($post->post_type == 'events') { // Check to see if Event Type.
    update_post_meta($post->ID, "event_featuring", $_POST["event_featuring"]);
    update_post_meta($post->ID, "event_time", $_POST["event_time"]);
    update_post_meta($post->ID, "event_date", $_POST["event_date"]);
    update_post_meta($post->ID, "event_end_date", $_POST["event_end_date"]);
    update_post_meta($post->ID, "event_location", $_POST["event_location"]);
    update_post_meta($post->ID, "empid", $_POST["empid"]);
    update_post_meta($post->ID, "bhs_event", $_POST["bhs_event"]);
    }
    }

    I tried using wp_insert_post_data instead of save_post, but then I had the opposite problem. It would save on Drafts, but publishing the post no longer worked. I tried calling both at the same time, same issue. What do I need to do differently so I can update a draft (before publishing) and it will save? I’m pretty sure this was working fine before I switched to 3.1.

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.