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

[5.x]: Create New User error in CP #16437

Closed
smockensturm opened this issue Jan 15, 2025 · 3 comments
Closed

[5.x]: Create New User error in CP #16437

smockensturm opened this issue Jan 15, 2025 · 3 comments
Labels

Comments

@smockensturm
Copy link
Contributor

What happened?

Description

System error when attempting to create a new user in the control panel.

Steps to reproduce

  1. Hit the +New user button

Expected behavior

A new user profile.

Actual behavior

TypeError at line 1026

craft\controllers\UsersController::actionCreate(): Return value must be of type yii\web\Response, null returned

Craft CMS version

Craft Pro 5.5.10

PHP version

8.2

Operating system and version

MacOS Sequoa 15.1.1

Database type and version

MySQL 8.0.27

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.1-43)

Installed plugins and versions

@brandonkelly
Copy link
Member

I can’t reproduce that, but it looks like it would happen if something is causing a validation error on the user that’s being created, preventing the element from getting saved.

I just added a check so if that happens, an exception will be thrown that lists any validation errors on the user, which should help point you in the right direction.

You can test that change by changing your craftcms/cms requirement in composer.json to:

"craftcms/cms": "5.x-dev as 5.5.10",

Then run composer update.

@smockensturm
Copy link
Contributor Author

Great. Thanks. if you are interested....

showFirstAndLastNameFields() is enabled.

Then we wish to validate these on a front end form.

So to fix we add a CP request check.

if (!Craft::$app->getRequest()->getIsCpRequest()) {
   $rules[] = [['firstName', 'lastName'], 'required'];
}

@brandonkelly
Copy link
Member

Craft 5.6.0 is out 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants