Support » Plugins » new plugin – how to retain checkbox status?

  • I’ve been learning how to write plugins lately (Delete Spam Daily & Google Chart Generator) and one question I still haven’t figured out is how to retain a checkbox status without writing to the database.

    I think you would have to write to the database to retain the value of a checkbox after a user leaves your plugin page. Or does anyone know another method?

Viewing 6 replies - 1 through 6 (of 6 total)
  • btw. any news on the progress of the plugin regarding using database fiels/values for the charts?

    Unfortunately I’m not able to add any features to this for a while. I’m entering grad school. Perhaps on a break? 🙂

    You can’t save the status of the checkbox without storing the data somewhere. The DB is the best place for that. If you are talking short term a cookie or $_SESSION might work. A cookie can save data for a long time but you can’t rely on it. A user can easily delete it, or alter it.

    Thanks apljdi. I think I came to that conclusion, but didn’t want to create a table just for a measly checkbox. 🙂 Though I seem to remember a way to add an entry to the options table…perhaps in the next release. 🙂

    WordPress has some pretty convenient ways to add to the tables, you don’t have to create your own. Probably a key/value combo in the usermeta table would do the trick.

    I found this link. I’ll try working it up on a break sometime. Thanks apljdi.

    WordPress Options Mechanism

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘new plugin – how to retain checkbox status?’ is closed to new replies.