PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Make an empty custom field write to DB

  1. branz
    Member

    Hi folks.

    I recently upgraded from 1.4.5 to 1.6.2.

    I have a form set up for users to create posts, which are basic - title, content, and custom fields.

    Two of my custom fields use the date picker and both are not required. Let's call them start_date and end_date.

    I have noticed that in 1.4.5 when I left either of those fields empty on the submission side, both meta keys were written in the postmeta table with no associated value.

    This is how I liked things.

    In 1.6.2 I have noticed that only those fields that have data in them get written to the database. So if I leave start_date or end_date empty then neither gets written as meta keys with an empty meta value in postmeta. Conversely, custom fields that do have something in the input box do get written properly.

    Is there a way to get empty custom field values to write the meta key and empty meta value as it was in 1.4.5?

    I have noticed that now for the date field I can have a default text string in the box, so that's a workaround (despite that it's a date field - previously this was not possible to do).

    I'd just like a permanent method that I can rely on, that won't change with future updates.

    Thank you!

    Posted 12 years ago on Thursday January 12, 2012 | Permalink