DUPLICATE: Dynamic Data: {url_parameter:redirect_to)

Browser: Edge 124
OS: macOS
URL: Local
Video: Jam

Trying to redirect the user on successful login to the url found in “redirect_to” url parameter. An example of what that url looks like with the parameter:
https://blueprint.local/login/?redirect_to=https://blueprint.local/members-only/

I have also tried the workaround in: academy article/form-element/#custom-redirect-to-hidden-field but the input field is not populated.

Hi Craig,
Welcome to the forum!

I’m not sure what’s causing your problem, but have you added the custom action to the functions.php of your child theme and adjusted it accordingly (form ID, hidden field ID)?

add_action( 'bricks/form/custom_action', 'redirect_to_my_key', 10, 1 );

function redirect_to_my_key( $form ) {
  $form_fields   = $form->get_fields();
  $form_id       = $form_fields['formId'];

  // Check if the form id is the one you want
  if( $form_id !== 'cyrozb' ) return;

  // oeckxw is the hidden field Id where I placed the 
  $my_key = isset( $form_fields['form-field-oecdxz'] ) ? $form_fields['form-field-oecdxz'] : '';

  if( $my_key ) {
    // Now you get the hidden field value and redirect to the page you want, for example:
   // $redirect_to = get_site_url() . '/?key=' . $my_key;

    // If the hidden field value is a URL, just redirect to it instead of following my code
   $redirect_to = $my_key;
    
    $form->set_result(
      [
        'action'          => 'my_custom_redirect', // This is the action name, you can set it to anything you want
        'type'            => 'redirect', // Must be set to 'redirect'
        'redirectTo'      => $redirect_to,
        'redirectTimeout' => 0 // Need to delay ? Set a timeout in milliseconds
      ]
    );
  }
}

In this case, the redirect works for me without any problems.

It would be great if you could make your website available live so that we can take a closer look at the problem. You can send access data and a link to this report to help@bricksbuilder.io when you are ready.

Best regards,
timmse

Hi Tim,

I did not go that far as I assume the field should first be populated as per the line where you are getting the value for $my_key (oeckxw is the hidden field Id where I placed the.)

I will however implement this to confirm I am not missing something and for completeness.

As for access I shell send accross some access details shortly.

I will also look to making the site available for you to inspect… but that might be a minute as it is running on my local machine at the moment using Local from WP Engine.

So I have migrated to a live site, not on local and though the original problem still stands, the workaround found below and mentioned above has provided me with a solution that works.

Workaround: Form Element – Bricks Academy (bricksbuilder.io)

Hi Craig,
The general issue has already been reported here:

As the workaround is working, I will close this thread as it is a duplicate. We will update the thread mentioned as soon as we have solved the problem.