Skip to content

How can i validate age from customer register?

I’m trying to validate the customer register field called Dob (Date of Birth) in the backend of my Magento 2.4.2.

If the age from the customer is under 18 years, i want to show a message in the frontend and get back to the register page ‘customer/account/create’.

I created a before plugin in MagentoCustomerControllerAccountCreatePost::execute() but I don’t know if this is the method I should intercept.

What is the easily and right way to do that?

Thx!