gmw_pt_update_location OR gmw_update_post_location not working properly.
-
Hi,
So I am using this script in order to write an address (and lat/lng info) to the database. This is however not always working.
Most of the times the record gets created in the mysql db, but sometimes it does not. Especially when using larger addresses/names.So, I have done A LOT of testing to see what is causing this. I did revert back to a twenty WP theme and disabled all other plugins with no luck.
Any idea why this is not working properly? I already found out something goes wrong with the
gmw_pt_update_location
function. And because it especially goes wrong with larger addresses/names, it might have to do with the google maps api response time? Any suggestions are welcome. ThanksI am trying to add the address with the following code
function gmw_update_post_type_post_location( $post_id ) { // Return if it's a post revision if ( false !== wp_is_post_revision( $post_id ) ) return; // check autosave // if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } //check if user can edit post if ( !current_user_can( 'edit_post', $post_id ) ) return; //Add post Meta add_post_meta($post_id, 'address', $_POST['address'], false); //get the address from the custom field "address" $addressarray = get_post_meta( $post_id, 'address', true ); $address = $addressarray[0]; //$address = $_POST['address']; //varify that address exists. Otherwise abort the function. if ( empty( $address ) ) return; //include the update location file file include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' ); //make sure the file included and the function exists if ( !function_exists( 'gmw_pt_update_location' ) ) return; //Create the array that will pass to the function $args = array( 'post_id' => $post_id, //Post Id of the post 'address' => $address // the address we pull from the custom field above ); //Add location gmw_pt_update_location( $args ); } //execute the function whenever post type is being updated add_action( 'save_post_mpp-gallery', 'gmw_update_post_type_post_location', 13, 1 );
The page I need help with: [log in to see the link]
- The topic ‘gmw_pt_update_location OR gmw_update_post_location not working properly.’ is closed to new replies.