1

Is there a way to create a pop-up for when someone visits the site on the backend of Craft?

1
  • 1
    To be clear, someone logs into the Craft control panel, and you want a pop-up/modal to display in the control panel?
    – Brad Bell
    Commented Sep 20, 2023 at 2:36

1 Answer 1

1

Yes, you will need to build a custom module that's built for the admin panel. A starter on doing so can be found here:

https://craftcms.com/docs/4.x/extend/

I think what you'll want is to trigger some code on the LOGIN event, but only if that user is has access to the CP. A quick search in Craft's Events lookup (located here: https://craftcms.com/docs/4.x/extend/events.html#event-code-generator) reveals this might be the event you want (feel free to dig / try others):

craft\elements\conditions\users\LastLoginDateConditionRule::EVENT_AFTER_VALIDATE

Events Guide: https://craftcms.com/docs/4.x/extend/events.html

You would write this in modules/Module.php (a pre-setup file in Craft CMS where you can code this) or your own custom equivalent.

1
  • You may want to code your own popup and NOT use the flash messaging, as its a bit reserved for particular use cases in the CP. Per this conversation: github.com/craftcms/cms/issues/6218
    – cherrykoda
    Commented Sep 21, 2023 at 1:27

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.