[wp-hackers] Setting default options for plugin

Callum Macdonald lists.automattic.com at callum-macdonald.com
Fri Aug 31 21:35:10 GMT 2007

Hey Stephen,

I think you want to use the activate_ action. See these pages for more info:

I've just created a plugin which does exactly that which you're welcome 
to copy. See lines 21-46 and 165 for the relevant code. The plugin is 
available here:



Stephen Rider wrote:
> Is there an official or "best" method for setting default options for 
> a plugin when it is first activated? Currently I use something like this:
> if (!get_option('my_plugin')){
> // set default options
> delete_option('my_plugin_options');
> add_option ( 'my_plugin_options',array( 'work_properly' => true ) );
> }
> This is just "raw" inside the php file (not in a function) so it runs 
> every time the PHP file is called. Is there a better way of doing this 
> or am I doing things right?
> Stephen
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list