Active
Project:
Profile
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Apr 2022 at 13:16 UTC
Updated:
5 Aug 2024 at 20:14 UTC
Jump to comment: Most recent
When registering new user via Commerce Login Pane, the profile shown on the user registration form is created but is assigned UID 0. When registering via user/register everything is correct.
Create New ProfileType shown on the user registration form. Allow to register new user on Checkout Login Pane. Register new account on Checkout. Profile is created but assigned to Anonymous User.
Comments
Comment #2
dunjincan commentedUpdate: The problem is the lack of permissions for the user to create profiles. At the same time, there is no setting to Create Only Own Profiles. The user/register form does not care about this and creates the user and then assigns him a profile. But form on Commerce New User Pane checks if the user has permissions and creates a profile but assigns it to user UID 0.
The solution is to grant profile creation privileges to the user.
Suggested solution: Add 'Create Own Profile' permission.
Comment #3
sébastien-frHow did you solve the issue ?
You simply grant to you custom profile creation to anonymous user ?
I don't use Commerce Login Pane but a custom form mode used to register user with a particular profile. The form works with Drupal fields. User is created and fields are saved and associated to the new created user. But profile created have UID 0 like you. I'm pretty sure it is the same problem (if I set the correct UID directly in DB, the profile is correct).
Comment #4
drupal_josh commentedPermissions didn't have an effect for us.
The issue seems to be that
\Drupal\profile\Plugin\Field\FieldWidget\ProfileFormWidget::saveProfilesisn't getting called by\Drupal\Core\Form\FormSubmitter::executeSubmitHandlers.And even if it did get called, Commerce's form is an instance of
\Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\MultistepDefaultwhich doesn't implement\Drupal\Core\Entity\EntityFormInterfacewhich this Profile module is expecting since it calls->getEntity()on this line:Not sure if this is the Profile module's issue or Commerce's, but it needs fixing either way!
So what I did was add a custom submit handler and just tweak that a little so it works with Commerce's
\Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\MultistepDefaultform object.This seems to work so far :
Comment #5
grimreaperHi,
I confirm the bug, on Profile 1.11.0. And that it is not a permission problem.
Thanks a lot for comment #4 which guided me to an updated workaround. Because proposition in comment 4 is no more usable.
First serialization of closure: needs to declare a proper function. Then the structure of what is gathered is different. Here is my poc:
Also, like mentioned in comment 4, in app/modules/contrib/profile/src/Plugin/Field/FieldWidget/ProfileFormWidget.php, saveProfiles is not triggered because in:
$form['actions']['submit']['#submit'] does not exist in in commerce checkout, it is 'register', and like mentioned, then you get a fatal error because:
This does not apply in the login pane.