Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Eyal Fitoussi

    (@ninjew)

    Hello @subwebsites,

    At the moment, there isn’t a shortcode that displays the raw value of the user’s location. But I am planning to add such a shortcode to the upcoming GEO my WP v4.0.

    Meanwhile, you can easily create this shortcode by adding the script below to the functions.php file of your theme:

    
    function gmw_custom_user_city_shortcode() {
    	return ! empty( $_COOKIE['gmw_ul_city'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['gmw_ul_city'] ) ) : '';
    }
    add_shortcode( 'gmw_user_city', 'gmw_custom_user_city_shortcode' );
    

    Then use the shortcode [gmw_user_city] anywhere on the site to display the user’s city.

    Let me know if this works or if you have any questions.

    Thread Starter Jaso

    (@subwebsites)

    Hi, that does not work on Mobile Devices, any help pls ??

    Thread Starter Jaso

    (@subwebsites)

    And doesnt work in Headings, neither in Elementor widgets or headings

    • This reply was modified 2 years, 11 months ago by Jaso.
    Thread Starter Jaso

    (@subwebsites)

    ok, got it to work, but doesnt work in Chrome, only Firefox

    Plugin Author Eyal Fitoussi

    (@ninjew)

    @subwebsites,

    The above solution should work on any device and anywhere on the page.

    You need to make sure that the current location of the user at all exists in GEO my WP and that it contains the city.

    You can do so by adding the Current Location shortcode or widget anywhere on your site and see if it returns the current location of the user and if it contains the city.

    If the Current Location does return the city but the shortcode above isn’t, then the issue might be with the script above. And if that’s the case, let me know and I will look into it again.

    Thread Starter Jaso

    (@subwebsites)

    Like I said, not working on Chromium, Chrome !

    Plugin Author Eyal Fitoussi

    (@ninjew)

    Does the Current Location shortcode display the user’s location with the city in it?

    Thread Starter Jaso

    (@subwebsites)

    only using Firefox browser, just like I’m trying to tell you.

    Not working in Chrome. Edge, or safari

    Test it yerself !

    Plugin Author Eyal Fitoussi

    (@ninjew)

    @subwebsites,

    I am confused as you are not being specific. What exactly isn’t working?

    There are 2 elements involved in here; the Current location shortcode [gmw_current_location] ( or widget ) that I asked you to add to the site and see if it generate the user’s location, and there is the [gmw_user_city] shortcode that is generated using the custom script above.

    So my question now is regarding the [gmw_current_location] shortcode/widget. Did you add it to your site, and if so, does it show the user’s location?

    And I am happy to have a look if you’d provide me with a link to the page where you added both shortcodes.

    Thread Starter Jaso

    (@subwebsites)

    I mentioned not working in certain browsers !
    Are you not comprehending this ?

    Plugin Author Eyal Fitoussi

    (@ninjew)

    I am truly being patience here and trying to help with this issue. So I’ll try to explain in more details.

    GEO my WP saves the user’s current location In cookies, so the fact that you see the current location on one browser doesn’t not mean that you will see it on another browser. So, in a particular browser, unless GEO my WP either automatically located the user or the user manually added his current location using the Current Location shortcode, you will not see the users current location.

    So to save your current in GEO my WP you need to add the Current Location shortcode ( [gmw_current_location] ) to your site.

    So I am asking again, did you add the current location shortcode to your site? And If so, can you provide a link to the page where you added that shortcode?

    Thread Starter Jaso

    (@subwebsites)

    I only wanted the city location name to appear: [gmw_user_city]

    Firefox shows: https://prnt.sc/IxzR03blea2l

    Chrome no show: https://prnt.sc/kbVXMBfymgwj

    Microsoft Edge no show: https://prnt.sc/94kE_rOdu06U

    All I wanted was to display the city name, nothing more

    Sooo, what now ??

    Plugin Author Eyal Fitoussi

    (@ninjew)

    If the city doesn’t show it means that GEO my WP has not been able to detect the current location of the user in those specific browsers.

    When a user first visits your site GEO my WP will ask to retrieve his current position. If the user denies it or if for some reason GEO my WP was unable to detect the location then the city wouldn’t show.

    GEO my WP will ask for the user’s location once in every 24 hours.

    So, the only other option to have the users location detected, except for the automatic detection of GEO my WP is allowing the user to enter manually using the Current Location shortcode.

    See this page -> https://docs.geomywp.com/article/169-current-location-overview For more info about the Current Location shortcode.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Show CITY name only’ is closed to new replies.