How to "force" customers to add address after registration?

Topic summary

A user seeks to redirect customers to the address form page (/account/addresses) immediately after registration, aiming to collect additional customer information that the default registration form doesn’t capture.

Attempted Solution:
They’ve tried implementing JavaScript code that:

  • Targets the registration form
  • Creates a hidden input field with name="return_to" and value="/account/addresses"
  • Appends this field to redirect users post-registration

Key Question:
The user wants to know if it’s possible to “force” customers to remain on the address page until the form is completed.

Current Status:
The discussion remains open with one other user expressing similar interest but no solution provided yet. The code snippet appears partially corrupted or reversed in the original post, which may indicate implementation challenges.

Summarized with AI on November 21. AI used: claude-sonnet-4-5-20250929.

Hi everyone!
I was trying to modify the default registration form, cause i need more information about my customers, but it’s almost impossible without apps.
So, after clicking on Submit on registration, the user will be redirected to the URL of the address in the account area.
I tried with something like this:

 <button>
      {{ 'customer.register.submit' | t }}<a href=""></a>
    </button>
    <script> 
   (function() { 
     var REDIRECT_PATH = '/account/addresses'; 
   
     var selector = '#create_customer, form[action$="/account"][method="post"]', 
         $form = document.querySelectorAll(selector)[0]; 
   
     if ($form) { 
       $redirect = document.createElement('input'); 
       $redirect.setAttribute('name', 'return_to'); 
       $redirect.setAttribute('type', 'hidden'); 
       $redirect.value = REDIRECT_PATH; 
       $form.appendChild($redirect); 
     } 
   })(); 
 </script> 
            {% if form.posted_successfully? %}
       <h1>COMPLIMENTI, CONTINUA A NAVIGARE</h1>
            {% else %}
               <script> 
   (function() { 
     var REDIRECT_PATH = '/account/addresses'; 
   
     var selector = '#create_customer, form[action$="/account"][method="post"]', 
         $form = document.querySelectorAll(selector)[0]; 
   
     if ($form) { 
       $redirect = document.createElement('input'); 
       $redirect.setAttribute('name', 'return_to'); 
       $redirect.setAttribute('type', 'hidden'); 
       $redirect.value = REDIRECT_PATH; 
       $form.appendChild($redirect); 
     } 
   })(); 
 </script> 
{% endif %}

Can i “force” the customers to stay on this page until the address form is filled?
Thank you so much in advance!

I have been trying to do this forever, did you ever figure it out