If you want to change customer group during registration by some request checkbox you can:
Create plugin for \Magento\Customer\Api\AccountManagementInterface
after method createAccount
and on update $customer group based on \Magento\Framework\App\RequestInterface
Or create observer on event customer_register_success
and update customer group.
You don't need to install any additional extension for this. If you have an issue with creating plugin or observer, I can prove the example. Let me know
[UPDATE]
In my example Acme
like vendor name, StackExchange
- module name
1. Register extension
app/code/Acme/StackExchange/registration.php
<?php
declare(strict_types=1);
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Acme_StackExchange', __DIR__);
2. Create module declaration
app/code/Acme/StackExchange/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Acme_StackExchange">
<sequence>
<module name="Magento_Customer"/>
</sequence>
</module>
</config>
3. Create Dependency Injection for set plugin
app/code/Acme/StackExchange/etc/di.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Customer\Api\AccountManagementInterface">
<plugin name="Acme_StackExchange_Plugin_Customer_Api_AccountManagementPlugin"
type="Acme\StackExchange\Plugin\Customer\Api\AccountManagementPlugin" sortOrder="10"/>
</type>
</config>
4. Create plugin
app/code/Acme/StackExchange/Plugin/Customer/Api/AccountManagementPlugin.php
<?php
declare(strict_types=1);
namespace Acme\StackExchange\Plugin\Customer\Api;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Framework\App\RequestInterface;
class AccountManagementPlugin
{
protected RequestInterface $request;
protected CustomerRepositoryInterface $customerRepository;
public function __construct(
RequestInterface $request,
CustomerRepositoryInterface $customerRepository
) {
$this->request = $request;
$this->customerRepository = $customerRepository;
}
public function afterCreateAccount(
AccountManagementInterface $subject,
CustomerInterface $result
): CustomerInterface {
// check if checkbox value set
if ($this->request->getParam('your_checkbox_name')) {
// set custom group
$result->setGroupId('GROUP_ID');
// save customer data
$this->customerRepository->save($result);
}
return $result;
}
}
5. Run setup upgrade
php bin/magento setup:upgrade
References: