TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.75k stars 431 forks source link

Callback on required plugin activated #791

Open SGr33n opened 4 years ago

SGr33n commented 4 years ago

Hi, I'm looking for a callback to call when the required plugin is activated. No mention about something like this on the configuration. I'm just looking for a way to set a custom option for the activated plugin. Does already exist an hook that allows to do something like this?

Thanks!

jrfnl commented 4 years ago

hi @SGr33n TGMPA does not offer any hooks for that but WP natively does offer a hook you can use activated_plugin. Using that hook, you will need to check that the $plugin which was activated was one of your required plugins, but I believe it should be usable for what you intend to do.

See: https://developer.wordpress.org/reference/hooks/activated_plugin/

Does that help ?

SGr33n commented 4 years ago

Thanks @jrnl! not at all, that's because if the user already activated the required plugin before I activate the TGMPA plugin it doesn't do the call. I think that TGMPA already do this check, in order to display the warning... we just have to know if there is some sort of hook.

jrfnl commented 4 years ago

@SGr33n Ah! Sorry, your question was a little ambigious.

In that case - you can use the (again) WP native is_plugin_active() method to check this for your required plugins.

Also see: #484 #485, #638.