[wp-hackers] Plugin options being cleared on save

Otto otto at ottodestruct.com
Mon Oct 18 17:53:28 UTC 2010


You don't need to include it as a hidden field, just remember that
your callback function has to return the entire array. It's going
straight into the database from there. So make sure you pull any
options you want to preserve out of the DB and put them in the new
array. Might be simplest to just pull out the existing array then
update it with the incoming options instead.

-Otto



On Mon, Oct 18, 2010 at 12:13 PM, Scott Bressler <sbressler at gmail.com> wrote:
> Thanks for the reply, John. Nope, I'm not - I was hoping that wasn't
> necessary. Nacin also mentioned this - could either include as a hidden
> field or re-add in the sanitization callback.
>
> Thanks!
>
> -Scott
>
> On Mon, Oct 18, 2010 at 10:10 AM, John Blackbourn
> <johnbillion+wp at gmail.com<johnbillion%2Bwp at gmail.com>
>> wrote:
>
>> Are you including the version number as a hidden field on the settings
>> screen so it gets saved with the other options? The entire contents of
>> the options field gets overwritten using the data that's submitted
>> (ie. it doesn't just update the array keys that are submitted).
>>
>> John
>>
>> On Mon, Oct 18, 2010 at 5:46 PM, Scott Bressler <sbressler at gmail.com>
>> wrote:
>> > I'm saving a plugin's options into a serialized array. On plugin
>> activation,
>> > I insert a version number into the array, which properly appears when I
>> > check the database. However, when I save the options that I added to the
>> > "Writing" screen (using add_settings_section, add_settings_field, and
>> > register_setting), which let the user change the other two settings in
>> the
>> > serialized array, the version number is removed from the array.
>> >
>> > Any idea why the version number is kicked out of the array on first save?
>> >
>> > Thanks!
>> >
>> > -Scott
>>  > _______________________________________________
>> > 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