Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#14192 closed defect (bug) (invalid)

Quick Edit On Custom Post Type Removes Custom Meta Values

Reported by: liamgooding's profile liamgooding Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Administration Keywords:
Focuses: 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 (1)

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

Download all attachments as: .zip

Change History (4)

@liamgooding
14 years ago

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

#1 @liamgooding
14 years ago

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

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 (?)

#2 @dd32
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#3 @dd32
14 years ago

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

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.