Title: Developing Plugin, wp_options data gets erased
Last modified: August 19, 2016

---

# Developing Plugin, wp_options data gets erased

 *  Resolved [brap](https://wordpress.org/support/users/brap/)
 * (@brap)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/developing-plugin-wp_options-data-gets-erased/)
 * Forgive me if this has been discussed before, I search around the forums and 
   did not find anyone else that has posted this problem
 * I am developing a plugin. I stored all my options into an array, serialize it,
   and save it into a field in the wp_options table using the add_option() function,
   or the update_option() when updating my plugins options.
 * This works great. However I have encountered a problem where when I went to reset
   the time and date on my wordpress blog, after saving it my options in the wp_options
   table for my plugin were reset to: s:2:”N;”;
 * It also did this when I changed the privacy settings on my blog. So I’m guessing
   this happens anytime a WordPress setting is changed.
 * Is there a hook or something else I need to do to have my options in wp_options
   saved when a WordPress setting is changed?
 * I’ve been looking through the source code of other plugins and I don’t see where
   they may be doing something like that, but there is a lot of code and I could
   be over looking it.
 * By the way, I am using wordpress 2.7.1, I don’t know if this occurs on other 
   wordpress versions.
 * Thanks!

Viewing 1 replies (of 1 total)

 *  Thread Starter [brap](https://wordpress.org/support/users/brap/)
 * (@brap)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/developing-plugin-wp_options-data-gets-erased/#post-1018105)
 * Guys and Gals,
 * I discovered my problem, I’m sorry for posting this issue as it was a logic error
   in my plugin. I’ve been working on this way too long today and I’m at the point
   I’m making stupid mistakes 🙂
 * I’ll explain what happened in case it may help someone else in the future.
 * In my plugin, I had a line of code that checked when the management page of my
   plugin submitted the form to update the plugin’s options, like this:
 *     ```
       if($_POST['action'] == 'update')
       {
       	// we are saving my_plugin options from my_plugin_manager.php
       	$sl->SaveOptions($_POST["my_plugin_options"]);
       }
       ```
   
 * The problem is that anytime a setting is updated under the Settings menu on wordpress,
   $_POST[‘action’] == ‘update’ is always true.
 * I needed to pass a hidden form variable as an identifier so that it would only
   update when the form was submitted from my plugins management page, like so:
 *     ```
       if($_POST['action'] == 'update' && $_POST['my_plugin_update'] == 1)
       {
       	// we are saving my_plugin options from my_plugin_manager.php
       	$sl->SaveOptions($_POST["my_plugin_options"]);
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Developing Plugin, wp_options data gets erased’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [brap](https://wordpress.org/support/users/brap/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/developing-plugin-wp_options-data-gets-erased/#post-1018105)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
