• I am creating a multisite for a local business with four locations. I’m going to use a multisite with subdirectories, with the root homepage being a landing “corporate HQ” type landing page with a selector to go to the site specific to one of the four locations, each of which will have it’s own site with the multisite.

    By default, users visiting the root domain will see the landing page. However, if they go to one of the location sites, I want them to automatically be redirected to the same location page on subsequent visits.

    Here’s how I thinking about doing it.

    1. On the HQ landing page, have some PHP code that checks if the “location” cookie is set, and if so, redirect to that location’s site. Use the isset and header PHP functions.

    2. On the HQ landing page, when the user clicks the link to go to a location’s site, add some onclick JS in the a tag to set the “location” cookie to that location with the jQuery.cookie JavaScript function (not sure if WordPress has jQuery installed by default)

    3. In the footer of the location sites, have a “change store location” a tag that goes to the HQ landing page, with onclick JS that uses jQuery.removeCookie to delete the “location” so the landing page loads instead of redirecting back.

    I think the above approach will work, but it seems hacky. Is this the right general way to do this? If so, is are there plugins that allow me to do all this without having to directly hack .php files?

    Thanks for any tips or guidance on how to achieve this the “right way.”

    • This topic was modified 4 years, 10 months ago by ghopper21. Reason: Fix code formatting
    • This topic was modified 4 years, 10 months ago by ghopper21. Reason: Fix code formatting some more
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Redirecting users to a specific location site they previously visited’ is closed to new replies.