Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to manually override geo-detection #94

Open
4 of 6 tasks
benjaminpick opened this issue Feb 23, 2021 · 1 comment
Open
4 of 6 tasks

Provide a way to manually override geo-detection #94

benjaminpick opened this issue Feb 23, 2021 · 1 comment

Comments

@benjaminpick
Copy link
Member

benjaminpick commented Feb 23, 2021

Is your feature request related to a problem / specific use-case? Please describe.

"My goal is to use this plugin to show country-specific content on certain pages. (using the shortcodes provided by the plugin)
We have a certain set of countries which we will have specific content. (US, CA, GB, …).
But we also would want the option to be able to switch between these countries so you can access any country-specific content."

https://wordpress.org/support/topic/region-select-2/

Describe the solution you'd like

"Also is it possible to overwrite the cookie with another value so it would load in the different country-specific content I mentioned?"

ToDos (details see post below):

  • JS function window.geoip_detect.set_override
  • When set_override is called, geo-conditionals (e.g. hide-if) need to execute again
  • country_selector receives a new parameter "autosave" which calls the JS function
  • country_selector receives a new parameter "list" which lets you enumerate the countries you want to show
  • PHP function `geoip_detect2_set_override_for_this_client($record, $duration = -1) [ For AJAX mode ]
  • PHP function `geoip_detect2_set_override_for_this_client($record, $duration = -1) [ For non-AJAX mode ]
@benjaminpick
Copy link
Member Author

benjaminpick commented Feb 23, 2021

Technical draft

AJAX mode: changing the cookie
Non-AJAX mode: set a cookie, [ sign it with a secret key (so it can't be forged) ? ], and if set, it will override the geo lookup function ...
(Should it use the same cookie format than the AJAX mode?)

API:

  • PHP function geoip_detect2_set_override_for_this_client($record, $duration = -1) / geoip_detect2_set_override_for_this_client_data($data, $duration = -1) (can work in AJAX and non-AJAX mode, enriches data)
  • JS function window.geoip_detect.set_override(record, duration) / window.geoip_detect.set_override_data(data, duration) (only works in AJAX mode, no enrichment or via AJAX)
  • country_selector receives a new parameter "autosave" which calls the JS function
  • country_selector receives a new parameter "list" which lets you enumerate the countries you want to show

Example:

window.geoip_detect.set_override_data({country: { iso_code: 'de' } }, 7 * 24 * 60 * 60)

benjaminpick added a commit that referenced this issue Sep 22, 2021
Implement AJAX Override Autosave (Ref #94 #140)
benjaminpick added a commit that referenced this issue Nov 9, 2021
Autosave (Implementing #94, restricting country list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant