Skip to content

Commit 8094daf

Browse files
committed
Don't set the default author if maxAuthors === 0
1 parent 7500941 commit 8094daf

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/controllers/EntriesController.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@ public function actionCreate(?string $section = null): ?Response
111111
$entry = Craft::createObject(Entry::class);
112112
$entry->siteId = $site->id;
113113
$entry->sectionId = $section->id;
114-
$entry->setAuthorIds(
115-
$this->request->getQueryParam('authorIds') ??
116-
$this->request->getQueryParam('authorId') ??
117-
$user->id
118-
);
114+
115+
if ($section->maxAuthors !== 0) {
116+
$entry->setAuthorIds(
117+
$this->request->getQueryParam('authorIds') ??
118+
$this->request->getQueryParam('authorId') ??
119+
$user->id
120+
);
121+
}
119122

120123
// Type
121124
if (($typeHandle = $this->request->getParam('type')) !== null) {

src/elements/Entry.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,10 +3015,11 @@ private function maybeSetDefaultAttributes(): void
30153015
return;
30163016
}
30173017

3018+
$section = $this->getSection();
30183019
if (
3019-
empty($this->getAuthors()) &&
3020-
!isset($this->fieldId) &&
3021-
$this->getSection()->type !== Section::TYPE_SINGLE
3020+
$section?->type !== Section::TYPE_SINGLE &&
3021+
$section?->maxAuthors !== 0 &&
3022+
empty($this->getAuthors())
30223023
) {
30233024
$user = Craft::$app->getUser()->getIdentity();
30243025
if ($user) {

0 commit comments

Comments
 (0)