Advertisement
pjeaje

How to use Geo Mashup with WP User Frontend posting form

Sep 24th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. // https://wordpress.org/support/topic/how-to-use-geo-mashup-with-wp-user-frontend-posting-form
  2. //  How to use Geo Mashup with WP User Frontend posting form
  3. // 1. name/rename the google maps custom field meta key as location
  4. // 2. Insert this into your theme's functions.php
  5.  
  6. add_action( 'added_post_meta', 'do_after_post_meta', 10, 4 );
  7. add_action( 'updated_post_meta', 'do_after_post_meta', 10, 4 );
  8. function do_after_post_meta( $meta_id, $post_id, $meta_key, $meta_value )
  9. {
  10.     if ( 'location' == $meta_key ) {
  11.         if( !empty ($meta_value) ):
  12.             $location_array = explode(",", $meta_value);
  13.             update_post_meta( $post_id, 'geo_latitude', $location_array[0] );
  14.             update_post_meta( $post_id, 'geo_longitude', $location_array[1] );
  15.         endif;
  16.     }
  17. }
  18.  
  19. // 3. update the Geo Mashup plugin Overall settings:
  20. // - Copy Geodata Meta Fields = tick this
  21. // - Geocode Custom Field = enter geo_latitude,geo_longitude,location
  22. //
  23. //Your mashups will now take the location as per your WP User Frontend form.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement