Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

public user registration logic amend #12544

Merged
merged 4 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fixed a bug where cancelling a conflicting volume folder move would result in the moved folder getting deleted.
- Fixed a bug where `craft\elements\Category::canDuplicate()` wasn’t factoring in save permissions.
- Fixed a bug where the horizontal scroll position wasn’t being retained when refreshing Live Preview. ([#12504](https://github.com/craftcms/cms/issues/12504))
- Fixed a bug where user group condition rules for the default user group weren’t getting matched properly during public registration. ([#12283](https://github.com/craftcms/cms/issues/12283))
- Deprecated `craft\helpers\DateTimeHelper::timeZoneAbbreviation()`.
- Deprecated `craft\helpers\DateTimeHelper::timeZoneOffset()`.

Expand Down
13 changes: 13 additions & 0 deletions src/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,19 @@ public function actionSaveUser(): ?Response
}
}

// If this is public registration and it's a Pro version,
// set the default group on the user, so that any content
// based on user group condition can be validated and saved against them
if ($isPublicRegistration) {
$defaultGroupUid = Craft::$app->getProjectConfig()->get('users.defaultGroup');
if ($defaultGroupUid) {
$group = Craft::$app->userGroups->getGroupByUid($defaultGroupUid);
if ($group) {
$user->setGroups([$group]);
}
}
}

// If this is Craft Pro, grab any profile content from post
$fieldsLocation = $this->request->getParam('fieldsLocation', 'fields');
$user->setFieldValuesFromRequest($fieldsLocation);
Expand Down