Ticket #14192 (closed defect (bug): invalid)

Opened 20 months ago

Last modified 20 months ago

Quick Edit On Custom Post Type Removes Custom Meta Values

Reported by: liamgooding Owned by:
Priority: normal Milestone:
Component: Administration Version: 3.0
Severity: normal Keywords:
Cc:

Description

Hi, just stumbled across this with a custom post type. I have a few custom meta boxes that very simply update meta values using

update_post_meta()

However, I just needed to run a quick edit on the date of a custom post type so used the 'inline editor' (or quick editor) and that worked fine but then looking at the full edit screen, all my custom meta values were wiped to blank.

The core features I'm supporting in my custom post type (title, editor, excerpt) were fine.

I've attached the plugin file that registers the custom post type along with meta-boxes. It's pretty barebones.

Attachments

fruitb_clients.php Download (8.2 KB) - added by liamgooding 20 months ago.
'clients' custom post type plugin with additional meta-boxes

Change History

'clients' custom post type plugin with additional meta-boxes

  • Status changed from new to closed
  • Resolution set to fixed

Okay nevermind my bug report.

When checking to update the custom meta fields (in your plugin file, or themes functions.php file) you can check for if it's the Quick Editor using:

if(!defined('DOING_AJAX'))
{
  // not using quick editor, continue to update meta fields
}

Sorry for the ticket, I've updated status to fixed (?)

  • Status changed from closed to reopened
  • Resolution fixed deleted
  • Keywords custom post type removed
  • Status changed from reopened to closed
  • Resolution set to invalid
  • Milestone Awaiting Review deleted

Checking to see if the constant is set is not a good idea either, The actions might be fired by something else edditing the post.

Instead, you should be outputting a nonce to your custom form, and checking that in your handler

ie.

function myplugin_handle_save() {
 if ( !isset($_POST['mynonce']) || !wp_check_nonce('somenonce', $_POST['mynonce']) )
   return;
  update_post_meta(.....)
}

(Note: That code is completely wrong, i'm not sure of the nonce checking function off the top of my head, you'd have to look it up, there are many cases of this mentioned in regards to custom post types.)

Note: See TracTickets for help on using tickets.