Skip to content

Forwarded parameter cause page not to load correctly #22965

@Caynexes

Description

@Caynexes

Issue Summary

When using the “Redirect on booking” option with forwarded parameters enabled and embedding the booking widget as a popup, the redirected URL includes not only the booking-related parameters, but also additional popup-specific parameters such as embed, layout, embedType, and overlayCalendar.

In my case, this caused the forwarded page to not load properly when using the latest version of WordPress. Independent of my case, I believe this might cause problems not only with WordPress. I believe the forwarded parameter should not include the popup-specific parameter to ensure the page that the user is forwarded to loads properly.

Steps to Reproduce

  1. Enable redirect on booking
  2. Enable forward parameters
  3. Embed the booking form as a pop-up

Technical details

To solve the problem, I used a custom JavaScript, which "cleaned" the URL. However, this should not be necessary.

Attached is the JavaScript that solved the forwarding of the unwanted parameters:

<script>
document.addEventListener("DOMContentLoaded", function () {
  // 1. Parse the current URL's search parameters.
  const searchParams = new URLSearchParams(window.location.search);

  // 2. Define the list of parameters you want to remove.
  const paramsToRemove = ["embed", "layout", "embedType", "overlayCalendar"];
  let changed = false;

  // 3. Loop through the list and delete each parameter if it exists.
  paramsToRemove.forEach(param => {
    if (searchParams.has(param)) {
      searchParams.delete(param);
      changed = true;
    }
  });

  // 4. If any parameters were removed, update the URL in the browser's address bar.
  if (changed) {
    const newSearch = searchParams.toString();
    
    // Rebuild the URL, preserving the path and hash (#), and adding the new query string.
    const newUrl = `${window.location.pathname}${newSearch ? '?' + newSearch : ''}${window.location.hash}`;
    
    window.history.replaceState(null, '', newUrl);
  }
});
</script> 

Metadata

Metadata

Assignees

Labels

Low priorityCreated by Linear-GitHub Syncembedarea: embed, widget, react embed🐛 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions