[wp-hackers] A Question On Plugins

Jamie Talbot wphackers at jamietalbot.com
Tue Apr 25 13:34:01 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andy Staines wrote:
> One of my plugins requires two tables to be created. I coded this up as
> a process in the 'activate' plugin hook. But for at least two people
> (and maybe more) when they have activated the plugin, the tables have
> not been set up. They are administrators of their blogs.
> 
> Is this the 'right' way to ensure tables get created or is there a
> better hook to use? And, if so, any ideas why it should fail?

One thing to remember is that the activate hook is dependent on the plugin name.  At first, I was
confused because I'd installed the plugin to its own directory, but not included that in the plugin
hook.  As in using:

add_action('activate_pluginname.php', array(&$this, 'activated'));

instead of:

add_action('activate_pluginname/pluginname.php', array(&$this, 'activated'));

Where the plugin files were in the directory 'wp-content/plugins/pluginname/'.  Other than them
installing to the wrong directory, no idea why it might be failing.  In any case, I decided to add
my tables on the first view of an options page, then used the activate hook to redirect the user
straight to that page when the plugin was first installed, instead of going back to the plugins
page.  That way, even if the activation screws up, my tables will still be created when they look at
the config page.

Cheers,

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFETiVJrovxfShShFARAkyBAJ9lQ8ipxBQHIDrZozETx8GXOJQMHgCeNtfG
hL0s97J+lBzz3z/fiWdsq64=
=m6yF
-----END PGP SIGNATURE-----


More information about the wp-hackers mailing list