phpwordpresspluginscodex

How can I have default values for options for a WordPress Plugin?


Or how can I populate wordpress database with default plugin values, add option doesnt works for me, like http://codex.wordpress.org/Function_Reference/add_option

I am sure my syntax is correct, what I want is, when the user goes to the settings menu of my plugin, he/she doesn't see the blank input field, rather see it filled with default data.


Solution

  • Just add the default values of your option(s) as the second parameter of the get_option() function call(s). Unless the option does not exists, this value will be returned then.