Is it possible to register an element source for a specific site ID, while it not appearing in another?

I have a module which is currently registering element sources, however we are now looking to use Craft CMS multi-site to house another site which doesn't need these element sources. Currently the code does not have any specific site/site ID awareness in the module as there has only even been one site.

What is the best way to ensure the element sources only appear on the desired site ID?

I'm referring to when going to entries and switching between the sites from the dropdown next to the entries header. For both sites the element sources are appearing. I only want them to appear on one. Many of the primary sites element sources that are out of the box Craft are removed, but not the custom element sources.


1 Answer 1


Turns out there is a sites key that can be set on an event source

$event->sources[] = [
    'key' => 'keyName',
    'sites' => 1,
    'label' => 'Source label',
    'criteria' => [
    'data' => [
        'handle' => 'exampleHandle',

The sites key can be set to a specific siteId value or an array of siteIds.

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.