functions – unregister_setting() vs delete_option() for plugin update


I have a plugin (my first major one) and I have some registered settings that are no longer needed. I would like to have these old settings removed from the database to tidy things up and not confuse users with the new settings that will be in the options table.

I set them like this:

register_setting('general_section', 'nav_option_one');
register_setting('general_section', 'nav_option_two');

When I tried to remove them with unregister_setting() nothing seemed to happen (at least on the DB):

unregister_setting('general_section', 'nav_option_one');
unregister_setting('general_section', 'nav_option_two');

I then when about it with delete_option() and it removed the row from the DB as expected. However, I am concerned I am missing something.

Can you please let me know what the best method of removing old options settings from the database and what’s supposed to happen when using unregister_setting() is used? I tried looking it up, but no help there:

Iisrael 2 years 2021-04-02T16:59:05-05:00 0 Answers 0 views 0

Leave an answer