{"action":"created","issue":{"url":"https://api.github.com/repos/halfempty/address-geocoder/issues/19","repository_url":"https://api.github.com/repos/halfempty/address-geocoder","labels_url":"https://api.github.com/repos/halfempty/address-geocoder/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/halfempty/address-geocoder/issues/19/comments","events_url":"https://api.github.com/repos/halfempty/address-geocoder/issues/19/events","html_url":"https://github.com/halfempty/address-geocoder/issues/19","id":102742266,"number":19,"title":"Accessing Lat and Lng from functions.php","user":{"login":"addzycullen","id":5970354,"avatar_url":"https://avatars.githubusercontent.com/u/5970354?v=3","gravatar_id":"","url":"https://api.github.com/users/addzycullen","html_url":"https://github.com/addzycullen","followers_url":"https://api.github.com/users/addzycullen/followers","following_url":"https://api.github.com/users/addzycullen/following{/other_user}","gists_url":"https://api.github.com/users/addzycullen/gists{/gist_id}","starred_url":"https://api.github.com/users/addzycullen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addzycullen/subscriptions","organizations_url":"https://api.github.com/users/addzycullen/orgs","repos_url":"https://api.github.com/users/addzycullen/repos","events_url":"https://api.github.com/users/addzycullen/events{/privacy}","received_events_url":"https://api.github.com/users/addzycullen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-24T08:57:22Z","updated_at":"2016-06-09T20:02:13Z","closed_at":"2016-06-09T20:02:13Z","body":" wondered if you might be able to help, Im trying to access the lat and lng of each post to insert into a new table in the database whoch is going to be base of another function.\r\n\r\nI have the post ID inserting into this table, however getting the lat and lng seems to be impossible, I've tried so many ways, If you could help, I would really appreciate it.\r\n\r\nHere's my function, if you can help i'd really appreciate it.\r\n\r\n    function save_lat_lng( $post_id )   \r\n    {  \r\n        global $wpdb;  \r\n        $fields = $_POST['acf']; \r\n    \r\n    global $post;\r\n    $custom_lat = $_POST[get_geocode_lat( $post->ID )]; \r\n    $custom_lng = $_POST[get_geocode_lng( $post->ID )];\r\n    // Check that we are editing the right post type  \r\n    if ( 'festival-event' != $_POST['post_type'] ) \r\n    {  \r\n        return;  \r\n    }  \r\n      \r\n    // Check if we have a lat/lng stored for this property already  \r\n    $check_link = $wpdb->get_row(\"SELECT * FROM lat_lng_post WHERE post_id = '\" . $post_id . \"'\");  \r\n    if ($check_link != null)   \r\n    {  \r\n        // We already have a lat lng for this post. Update row  \r\n        $wpdb->update(   \r\n        'lat_lng_post',   \r\n        array(   \r\n            \"lat\" => $custom_lat,\r\n            \"lng\" => $custom_lng \r\n        ),   \r\n        array( 'post_id' => $post_id ),   \r\n        array(   \r\n            '%f',  \r\n            '%f'  \r\n        )  \r\n        );  \r\n    }  \r\n    else  \r\n    {  \r\n        // We do not already have a lat lng for this post. Insert row  \r\n        $wpdb->insert(   \r\n        'lat_lng_post',   \r\n        array(   \r\n            'post_id' => $post_id,  \r\n            \"lat\" => $custom_lat,\r\n            \"lng\" => $custom_lng\r\n        ),   \r\n        array(   \r\n            '%d',   \r\n            '%f',  \r\n            '%f'  \r\n        )   \r\n        );  \r\n    }  \r\n    }  \r\n    add_action( 'save_post', 'save_lat_lng' )```"},"comment":{"url":"https://api.github.com/repos/halfempty/address-geocoder/issues/comments/225009447","html_url":"https://github.com/halfempty/address-geocoder/issues/19#issuecomment-225009447","issue_url":"https://api.github.com/repos/halfempty/address-geocoder/issues/19","id":225009447,"user":{"login":"mgibbs189","id":115410,"avatar_url":"https://avatars.githubusercontent.com/u/115410?v=3","gravatar_id":"","url":"https://api.github.com/users/mgibbs189","html_url":"https://github.com/mgibbs189","followers_url":"https://api.github.com/users/mgibbs189/followers","following_url":"https://api.github.com/users/mgibbs189/following{/other_user}","gists_url":"https://api.github.com/users/mgibbs189/gists{/gist_id}","starred_url":"https://api.github.com/users/mgibbs189/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgibbs189/subscriptions","organizations_url":"https://api.github.com/users/mgibbs189/orgs","repos_url":"https://api.github.com/users/mgibbs189/repos","events_url":"https://api.github.com/users/mgibbs189/events{/privacy}","received_events_url":"https://api.github.com/users/mgibbs189/received_events","type":"User","site_admin":false},"created_at":"2016-06-09T20:02:13Z","updated_at":"2016-06-09T20:02:13Z","body":"Sorry, this isn't a support forum :\\"}}
{"actor":{"display_login":"mgibbs189"}}