TransWikia.com

How to auto enable a plugin after install?

Craft CMS Asked on December 4, 2021

I am developing a plugin for craft 3 and the plugin just got published to the store.

I can browse through the store and install the plugin but it stays disabled. The user will have to goto Settings -> Plugins and then manually enable the plugin even after installing. Is there a way to auto enable the plugin after install?

Example

One Answer

It's because the plugin is doing this in the init():

https://github.com/poptins/craftcms-poptin-app/blob/master/src/Poptin.php#L69-L74

That's basically overwriting Craft's default Project Config settings for a plugin (which is to be enabled).

https://github.com/craftcms/cms/blob/develop/src/services/Plugins.php#L536-L545

If you keep it there, then you'll have to explicitly set it to enabled in Project Config as well, but ideally, you'll want to move that logic out of init() and into something like an EVENT_AFTER_INSTALL_PLUGIN event.

Answered by Brad Bell on December 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP