Skip to content

Instantly share code, notes, and snippets.

@svenl77
Last active July 27, 2017 11:18
Show Gist options
  • Save svenl77/d0fcea2746481bd9c4fecd79b60d36c4 to your computer and use it in GitHub Desktop.
Save svenl77/d0fcea2746481bd9c4fecd79b60d36c4 to your computer and use it in GitHub Desktop.
BuddyForm GEO my WP Location Update after Save or Update a Post
<?php
// Update the geo location after save or update the post with buddyforms
add_action('buddyforms_after_save_post', 'my_buddyforms_gmw_update_location', 10, 1 );
function my_buddyforms_gmw_update_location( $post_id ) {
//make sure we have post ID
if ( !$post_id )
return;
//change meta_field_name to the BuddyForms Form Lelement SLUG of the address field
$address = get_post_meta( $post_id, 'SLUG', true );
//include geocoder file
include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );
if ( function_exists( 'gmw_pt_update_location' ) ) {
//setup geocoder args
$args = array(
'post_id' => $post_id,
'post_type' => get_post_type( $post_id ), // change post_type to your own
'post_title' => get_the_title( $post_id ),
'address' => $address
);
//run geocoder function
gmw_pt_update_location( $args );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment