A
A
Alejandro Matias2017-06-01 13:14:06
PHP
Alejandro Matias, 2017-06-01 13:14:06

How to redirect to regional sections?

There is a bulletin board site with pages of categories and regions, as well as pages of search results for a filter of the form: category + region (with its own url).
The question is how to redirect the user to the regional sections? And in the future to assign it to these regions, that is, so that on the site he sees links "category + region" with his region.
When entering the site, the visitor's region is determined automatically by ip, confirms the region. Further, the visitor goes only on their regional links (of the type "category + region" ) and sees only them. That is, you need to change blocks with links on the site or substitute the necessary regional urls.
The visitor can change his region at any time if he wishes.
Site on one domain (no subdomains) on Wordpress, theme based on woocommerce.
How is it possible to implement this? Give advice please.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nastya Sukharik, 2017-06-01
@extstar

you write down in session the region.
then when you go to any page you check if there is one, then show it.
that is, in function.php - check, if yes, throw the region
further into the session in the template; if this region is in the session, then show it.

W
WordPress WooCommerce, 2017-06-05
@maxxannik

There is an opinion that the use of sessions should be with extreme caution and only where without them, well, finally, in any way. Otherwise, there is a risk of grabbing large loads and brakes.
Probably better to take the same mechanism by which the site remembers users - cookies.
When choosing a city, just put the cookie with the city. And then you can check the cookie, filter requests, content and any other dances.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question