[wp-hackers] Setting default options for plugin

John Blackbourn johnbillion+wp at gmail.com
Fri Aug 31 22:38:09 GMT 2007


Stephen,

You should use the register_activation_hook function instead of
calling the activate_xxx action directly. Unfortunately this isn't a
well documented function.

Brief explanation here:
http://wphooks.flatearth.org/hooks/activate_plugin-filename/

John.

On 8/31/07, Callum Macdonald <lists.automattic.com at callum-macdonald.com> wrote:
> Hey Stephen,
>
> I think you want to use the activate_ action. See these pages for more info:
> http://codex.wordpress.org/Plugin_API/Action_Reference
> http://codex.wordpress.org/Creating_Tables_with_Plugins
>
> 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:
> http://www.callum-macdonald.com/code/wp-mail-smtp/
>
> Cheers,
>
>
> Callum.
>
> 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
> >
> >
>
> _______________________________________________
> 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