For some reason, I’ve never encountered this before even though I’ve done lots work with members and users. I have a bunch of user attributes that are flagged as below. When I enter a member via the Dashboard, the attributes flagged as 'Require on Registration Form" complain if I leave these blank. My feeble mind thinks that adding a member through the Dashboard by the Super Admin should be able to override these flags because I’m not using the ‘Register’ page or the registration form. The use case is that I need to add a ‘stub’ of a member and then when they log in, they are prompted to ‘fill in the blanks’. Any thoughts are appreciated.
If you are “registering” them manually in the dashboard so they can log in, will they ever see the registration page? I would think if you uncheck them you would be good to go. They will log in, go to their profile and be able to edit them there, without you being forced to enter anything in them!
Well, that sounds fine except I WANT them to be forced to enter certain fields upon logging in and I’m pretty sure that was the behavior way back in 5.7-ish (??). If my memory serves me, I believe I set it so that the login destination was their profile. If I flagged something as “Editable and Required in Profile” then when they landed on their profile, they’d be prompted for those things. It stops me from having to ‘chase’ members for required information. Did I dream all this once upon a time?
Its exactly what happens. If you add them in the members area when they first login they are taken to a page with the extra required fields.
You can test this by adding a required field to the registration then loging out and back in.
One thing to note if this doesn’t happen make sure you have the right code in your theme.
I wonder if I’ve over-ridden something somewhere. It was a couple of years ago when I built this site so I’ll have to deep a little deeper. Thx folks.
Switch the theme to default and try it. Also see if you have any registration or login page overrides and turn them off.
I do have a registration override but it just adds better labels to the inputs. I haven’t turned it off to see what happens. Other stuff on my plate at the moment (wife’s errands). It’s the Atomic theme so I’m pretty sure I haven’t messed with that.
I’ve removed the custom register.php file from the system and it doesn’t fix the problem. I’ve spun up a temporary site on concretecms.org and the same issue exists. Any attribute flagged as ‘Require on registration form’ is also required when I add a user through the Dashboard. If I add ‘dummy’ content to get the person in the system then, of course, when they log in and go to their profile, the system won’t insist on getting their true info because it already has junk in there.
Getting technical, line 69 of concrete/controllers/single_page/dashboard/users/add.php specifically checks to see if the attribute is required on the registration form so it looks like this is by design. On submit, lines 66->69 check it. Maybe I’ll try bypassing that check if it’s the Super Admin adding a user and see if things crash and burn.
$response = $validator->validateSaveValueRequest(
$controller,
$this->request,
$uak->isAttributeKeyRequiredOnRegister()
);
Well, that solves my immediate problem. Simply wrapping that error-trapping code at line 71 with:
$app = app();
$u = $app->make(\Concrete\Core\User\User::class);
if (!$u->isSuperUser()) {
if (!$response->isValid()) {
$error = $response->getErrorObject();
$this->error->add($error);
}
}
allows the Super User to add members without adding any of the fields flagged as ‘Require on registration form’. I’ll see if there are any unintended consequences.
Great solution! You going to do a pull request for that on Github? I think it should be baked into the core.
I’m not really sure if it should be baked in or it should be an option. I have had no unintended consequences but maybe folks wiser than me know a reason why this would be a bad thing.
Best bet is to do a pull request and if it gets rejected, then we’ll know.