1

I have made custom registration form which uses Magento's createPost for creating a new customer. On registration fail it is redirecting to customer/account/create

I would like it to redirect it to the custom form page again. How to achieve this?

There is no event in Magento for customer registration fail. Also if I want to create a preference of CreatePost controller I don't know how to achieve this functionality

2 Answers 2

0

You need to pass some additional parameter with registration form post parameter to CreatePost controller, which identifies that the request is made from custom registration form.

And then you can check whether your custom parameter is available in post data, depending on it you can redirect the request to the custom registration page post registration failure.

1
  • @SuiyanKhot Is it helped you? May 4, 2021 at 7:33
0

The purpose is to replace redirect URL from customer/account/create/ to own in case of this query from your own page form.

Try to add the "before" plugin for this method:

\Magento\Framework\HTTP\PhpEnvironment\Response::setRedirect

with something like this (it's a raw code - probably you need to avoid directly using the $_SERVER variable in magento, etc.):

        if (strpos($_SERVER['HTTP_REFERER'], 'you_custom_form_page_url_request') !== false
            && strpos($url, 'customer/account/create/') !== false
            && $code === 302
        ) {
            $url = 'you_custom_form_page_full_url';
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.