From 0025b42b1a8341cd21771ded945af35c5e78af85 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 27 Mar 2024 11:33:35 -0500 Subject: [PATCH] Don't allow Admin condition rules in Solo/Team --- CHANGELOG.md | 3 +++ src/elements/conditions/users/AdminConditionRule.php | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad2dfa0374..49aa53cd659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Release Notes for Craft CMS 5 +## Unreleased +- Fixed a bug where “Admin” rules were available to user conditions in Solo and Team editions. + ## 5.0.0 - 2024-03-26 ### Content Management diff --git a/src/elements/conditions/users/AdminConditionRule.php b/src/elements/conditions/users/AdminConditionRule.php index 54b812d48dc..a84d411a4a9 100644 --- a/src/elements/conditions/users/AdminConditionRule.php +++ b/src/elements/conditions/users/AdminConditionRule.php @@ -9,6 +9,7 @@ use craft\elements\db\ElementQueryInterface; use craft\elements\db\UserQuery; use craft\elements\User; +use craft\enums\CmsEdition; /** * Admin condition rule. @@ -26,6 +27,14 @@ public function getLabel(): string return Craft::t('app', 'Admin'); } + /** + * @inheritdoc + */ + public static function isSelectable(): bool + { + return Craft::$app->edition === CmsEdition::Pro; + } + /** * @inheritdoc */