Last active
July 27, 2017 11:18
-
-
Save svenl77/d0fcea2746481bd9c4fecd79b60d36c4 to your computer and use it in GitHub Desktop.
BuddyForm GEO my WP Location Update after Save or Update a Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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