Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New post has no status #394

Closed
RoccoMarco opened this issue Apr 27, 2017 · 3 comments
Closed

New post has no status #394

RoccoMarco opened this issue Apr 27, 2017 · 3 comments

Comments

@RoccoMarco
Copy link

Creating new post I was expecting that status will be the one I have chosen as default.

The status is empty. Taking a look to database it is saved as autodraft.

Is this a bug?

@RoccoMarco
Copy link
Author

RoccoMarco commented Apr 27, 2017

Looking at database the problem is that autosave saves the post as auto-draft or draft. I have solved this using this filter

/**

  • @brief Fires on post insert forcing default state according to edit flow.
  • @param[in] array $postdata the post data as a keyed array.
  • @return array the modified post data.
    */
function pe_post_save($postdata) {
  if((strcmp($postdata['post_status'], 'draft') == 0) ||
     (strcmp($postdata['post_status'], 'auto-draft') == 0)) {
    global $edit_flow;
    if(is_a($edit_flow, 'edit_flow')) {
      $status = $edit_flow->custom_status->get_default_custom_status()->slug;
      $postdata['post_status'] = $status;      
    }
  }
  return $postdata;
}
add_action( 'wp_insert_post_data', 'pe_post_save');

@pyronaur
Copy link
Member

pyronaur commented Jan 18, 2018

Hi @RoccoMarco,
WordPress is automatically saving auto-drafts for you even when you don't save your posts. I think that they shouldn't be turned into "Pitches" (or whichever default status you've given your edit flow). Auto-drafts are and should be hidden from calendar - when the author saves a post - it will appear on the calendar. This way, while someone is working on a draft - it won't appear on the calendar, and when they click "Save Post" it'll have the default status and show up.

@dchymko
Copy link
Contributor

dchymko commented Oct 31, 2019

Sounds like this may not be a bug, as auto-saves are working as intended here. Will close this issue out for now, but feel free to re-open if there is additional context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants