Can I assign specific roles when a user registers?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 5 años
I want to auto assign specific customer roles when a user registers. It needs to be a bit more specific than just "registered"? Is this possible?

Chip
Hace 5 años
Hello Chip,

It is not possible out of box in nopCommerce. By default a system role "Registered" is applied to every customer in nopCommerce when they register on website.


However, you can customize and set this to be selected by you that which role other than registered should be applied to a customer after successful registration.

Also, if you want a customer role based on some input from customer in registration form then that is also possible.

In short, registered role is compulsory for a customer and you can customize to assign any other custom / system roles in nopCommerce.

Hope this answer would be helpful for you.
Hace 5 años
FYI, Roles do have this property:

Roles Purchased with product

"A customer is added to this customer role once a specified product is purchased (paid). Please note that in case of refund or order cancellation you have to manually remove a customer from this role.
Hace 5 años
What New York said is correct. This feature can be used to implement paid membership. :)


Hace 4 años
nopAdvance.com wrote:

However, you can customize and set this to be selected by you that which role other than registered should be applied to a customer after successful registration.

Also, if you want a customer role based on some input from customer in registration form then that is also possible.



Could you provide any information you have on where this customization takes place? Is it through store settings or with custom code? Thank you!
Hace 4 años
Hi,

When a new customer is registered in nopCommerce v4.20 two events are raised:
1. _eventPublisher.EntityInserted(customerPassword);
2. _customerService.UpdateCustomer(request.Customer);

You can either create a plugin that is listening for those events and assigning the role or you can create custom class inherited from CustomerRegistrationService and override RegisterCustomer method. Then you must replace ICustomerRegistrationService implementation in nopCommerce DI container.
Hace 4 años
The easiest way is to create a new implementation for CustomerRegisteredEvent. Here write required code to add new role to the customer.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.