Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter jbkeefer

    (@jbkeefer)

    It appears you store the geo data as cookies, so nothing is written to WP user meta. Is that true?

    Plugin Author Eyal Fitoussi

    (@ninjew)

    Hi,
    The visitor’s/user’s current position is indeed being saved in cookies. But other information like posts location and members location ( when used with BuddyPress ) is saved in custom database table.
    You can however use a filter that executes every time a user uses the current location widget/shortcode to retrieve his current location and save his data in user meta.

    I can provide you with the right filter if that’s what your looking to do.

    Thread Starter jbkeefer

    (@jbkeefer)

    That is indeed what I am trying to do. I would be interested to see what you hook into and the filter. In the meantime, I will take a look at the current location widget/shortcode you reference. Not sure what that is.

    Thank you for the reply.

    jamie

    Thread Starter jbkeefer

    (@jbkeefer)

    Eyal

    I am writing a simple plugin to write the lat lon to user meta. Dont sweat the filter.

    Thanks again!

    Jamie

    Plugin Author Eyal Fitoussi

    (@ninjew)

    HI Jamie,
    Sorry I missed your previous reply.

    Let me know if you change your mind about the filter.

    Regard,

    Thread Starter jbkeefer

    (@jbkeefer)

    Eyal,

    Well I’m back…

    Is there any way I can try your filter solution?

    I have a script I am working on but it’s taking me longer than I expected. Debugging the ajax is frustrating me, I have something that should work but it’s not, and I haven’t even added the automation.

    Can you help a guy out? ??

    Thank you,

    Jamie

    Plugin Author Eyal Fitoussi

    (@ninjew)

    Sure,
    The action hook is

    do_action( 'gmw_user_current_location_submitted', $_POST['gmw_cl_location'], get_current_user_id() );

    and can be found in geo-my-wp/plugins/current-location/includes/geo-my-wp-current-location-class.php.

    So you can try the script below which suppose to update the user_meta of the logged in user when he uses the curretn location shortcode/widget:

    function gmw_add_current_location_to_user_meta( $location, $user_id ) {
    
        // abort if user is logged out
        if ( empty( $user_id ) )
            return;
    
        update_user_meta( $user_id, 'latitude', $location['lat'] );
        update_user_meta( $user_id, 'longitude', $location['lng'] );
        update_user_meta( $user_id, 'address', $location['formatted_address'] );
    }
    add_action( 'gmw_user_current_location_submitted', 'gmw_add_current_location_to_user_meta', 10, 2 );

    $location is array that holds all of the location fields.

    Let me know if that helps.

    Thread Starter jbkeefer

    (@jbkeefer)

    Eyal,

    thank you very much for taking the time to get this to me. I do appreciate it.

    I will play with it and see how it works.

    Peace,

    Jamie

    Thread Starter jbkeefer

    (@jbkeefer)

    Eyal,

    thank you very much for taking the time to get this to me. I do appreciate it.

    I will play with it and see how it works.

    Peace,

    Jamie

    Thread Starter jbkeefer

    (@jbkeefer)

    Didn’t seem to work with the widget. My attempts to “get location” resulted in endless spinner.

    thank you for your time with this, but if it requires user input, it’s the same that I have currently. I’ll just leave it as is and continue trying to debug my plugin. I have to learn how to use ajax, but I think WordPress is making this harder than usual. ??

    jamie

    i can’t get exact user’s current location,
    can u help me out ???

    I have tried using this script, but it is not saving in user_meta table.

    The widget in my search form finds an address, and re-organizes the search by location. So that part seems to be working fine.

    I just get nothing saved to my user_meta table. Any help getting this working would be greatly appreciated.

    Thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Automatic User Location’ is closed to new replies.