[wp-hackers] Custom Fields -- Lost by Autosave??

Sharon Chambers sharon at BrewerRadio.com
Thu Sep 17 19:32:00 UTC 2009


Thanks, John.
I'm not sure I follow though...

It's not that I'm saving data for an autosave version, it's that my custom field is simply removed from the post.  Darndest thing, really.

Good call for the revision check, though.  I'll see if I can't re-enabled that feature.

Want me to setup an account for you to see what I'm talking about?
-Sharon


-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of John Blackbourn
Sent: Thursday, September 17, 2009 3:26 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] Custom Fields -- Lost by Autosave??

Sharon,

When saving the custom field data inside the function that gets called
with the save_post (or edit_post, can't remember off the top of my
head) hook, you need to check that the post being saved isn't a
revision or an autosave.

Eg I use the following code:

if ( wp_is_post_revision( $post_ID ) or wp_is_post_autosave( $post_ID ) )
	return;

HTH, John.

2009/9/17 Sharon Chambers <sharon at brewerradio.com>:
> I've been testing some more...
> It appears that a standard custom field (i.e., NOT one appended with underscore _), does not get affected the same way.  Is there special handling of "hidden" custom fields?  Or is there something else I'm not seeing...
>
>
>
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Sharon Chambers
> Sent: Thursday, September 17, 2009 1:29 PM
> To: 'wp-hackers at lists.automattic.com'
> Subject: [wp-hackers] Custom Fields -- Lost by Autosave??
>
> I originally posted this on Wordpress.org forum, but was directed here by a moderator.
> Here's my question, I'll be happy to forward code, login, etc, to anyone willing to help debug:
>
> I'm writing a custom events plugin that integrates to the Wordpress edit post/page admin screen, and it works like a charm...
> that is, until you leave the post open in the editor for "too long" (i'm guessing over 2 minutes, though I haven't verified this yet...that's the length of my autosave interval). Here's the gist:
> My plugin adds an event box to the sidebar of the edit post/page screen using the following hooks/filters:
> edit_post, publish_post, save_post, delete_post, admin_menu, manage_posts_columns, manage_pages_columns
> When a post/page is published, if this event box is checked, then I write some stuff to the database and add 2 custom fields to the post/page: _bec_expiration (the expiration date of the event) and _bec_id (the db id of the event). (The underscores are so Wordpress doesn't display in the standard custom field section).
> However, if I then leave the post up in the editor for a few minutes (?2 or longer?), then return and leave the page (without changing and/or updating my post), my custom fields, and hence my event information, is gone! -poof!-
> I'm unable to find a hook into the autosave feature of Wordpress, and I'm unable to disable this functionality. (I already had to disable revisioning which interfered with my plugin also by pulling the post revision id instead of the post id).
> Any ideas?
>
>
>
> Sharon Chambers
> Webmaster
> brewer media
> 1305 Carter Street
> Chattanooga, TN 37402
> (423)242-7652 office
> (423)266-2335 fax
> Sharon at BrewerMediaGroup.com
> Brewer Broadcasting:
> Power 94.9 | Groove 93.7 | ESPN Chattanooga 105.1 | Pulse News 95.3
> Brewer Interactive:
> BOGONooga.com | ChattanoogaLivesGreen.com | ChattanoogaHasFun.com | ChattanoogaHasCars.com | ChattanoogaHasTravel.com | ChattanoogaCrime.com
> Brewer Publishing:
> ChattanoogaPulse.com, The Pulse - Chattanooga's Alternative Weekly Newspaper
> Chattanooga Traffic Network:
> 17 Radio Stations | 3 Television Stations | Traffic Reports & Sponsorships
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list