WordPress.org

Ready to get started?Download WordPress

Forums

new plugin - how to retain checkbox status? (7 posts)

  1. brockangelo
    Member
    Posted 5 years ago #

    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?

  2. Ovidiu
    Member
    Posted 5 years ago #

    btw. any news on the progress of the plugin regarding using database fiels/values for the charts?

  3. brockangelo
    Member
    Posted 5 years ago #

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

  4. s_ha_dum
    Member
    Posted 5 years ago #

    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.

  5. brockangelo
    Member
    Posted 5 years ago #

    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. :)

  6. s_ha_dum
    Member
    Posted 5 years ago #

    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.

  7. brockangelo
    Member
    Posted 5 years ago #

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

    WordPress Options Mechanism

Topic Closed

This topic has been closed to new replies.

About this Topic