1

Is there an action hook when a new plugin is installed?

I want to hook into the moment when a new plugin was put into the /wp-content/plugins folder. So really just adding the plugin (either via upload or via installation through the admin interface to pick plugins for installation).

Please note I am not referring to the activation of a plugin (activated_plugin does that trick).

7
  • There's no hook for that that I know of. hookr.io is pretty useful for browsing all of the hooks at once.
    – admcfajn
    Commented Jan 10, 2022 at 22:57
  • 1
    you would need to check for this on every single request and then fire a hook yourself to catch when someone drops a plugin in that folder via FTP or other means, which could be costly. You'd also need to maintain a list. What's the reason for wanting to do this? What are you trying to do that requires it?
    – Tom J Nowell
    Commented Jan 11, 2022 at 0:44
  • Is it your plugin that you can code?
    – brothman01
    Commented Jan 11, 2022 at 18:39
  • There is a need for a server-side script, nothing to do with WordPress.
    – Max Yudin
    Commented Jan 11, 2022 at 21:38
  • @TomJNowell Adding folders via FTP is out of scope. I am only concerned what WordPress offers via the admin UI. So the package upload and "online install" from the WP.org repo. I had hoped I can get an info for that cases.
    – hbit
    Commented Jan 11, 2022 at 22:24

1 Answer 1

0

I think it's a bit tricky but using https://developer.wordpress.org/reference/hooks/plugin_loaded/ to know if the plugin has just been activated.

I think check if a plugin is added to get_option('active_plugins');

And doing your stuff when you detect something new

1
  • How does this help to recognize the plugin installation? Again: not talking about the activation with my question.
    – hbit
    Commented Jan 11, 2022 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.