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?


One Answer

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

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

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!

Related Questions

Strange 404 Errors

1  Asked on May 27, 2021


Contact Form – Missing submissions

1  Asked on May 27, 2021 by springboynick


Duplicate content from www and non-www

2  Asked on May 27, 2021 by alex-carpenter


Seomatic – show only global site title

2  Asked on May 24, 2021 by filip-bartnicki


PHP Login & Sessions without Craft Commerce?

1  Asked on May 23, 2021 by jtr


Prevent caching from inside of the cache tag

2  Asked on May 23, 2021 by matthias-redl-mann


Redirect after password reset

0  Asked on May 22, 2021


Filter locations by country in Smart Map

2  Asked on May 21, 2021 by tom-de-smet


Where does Craft store HTML Templates?

1  Asked on May 18, 2021 by jordan-rennick


Invalid path alias: @ error

1  Asked on May 17, 2021 by tim-print


Form field as ‘Upload Location Subfolder’

0  Asked on May 15, 2021 by john-dunkel


Store Hours field in Matrix

0  Asked on May 15, 2021 by fodney


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir