[themify_is_logged_in]
[php]
function update_GEOmyWP( $post_id ) {
// make sure post ID exists.
if ( ! $post_id ) {
return;
}
// verify the updater function.
if ( ! function_exists( ‚gmw_update_post_location‘ ) ) {
return;
}
if ( isset( $_POST[‚aufnahmeort‘] ) ) { // Aufnahmeort ist der Key des Feldes
list( $adresse, $lat, $lng ) = explode( ‚||‘, $_POST[‚aufnahmeort‘] );
$location = array(
‚lat‘ => (float)$lat,
‚lng‘ => (float)$lng
);
if ( $adresse ) {
update_post_meta( $post_id, ’newADDRESS‘, $adresse );
}
if ( $lat ) {
update_post_meta( $post_id, ’newLAT‘, $lat );
}
if ( $lng ) {
update_post_meta( $post_id, ’newLONG‘, $lng );
}
if ( $summe ) {
update_post_meta( $post_id, ’newAUFNAHMEORT‘, $summe );
}
//run the udpate location function
gmw_update_post_location( $post_id, $location );
}
}
add_action( ‚wpuf_add_post_after_insert‘, ‚update_GEOmyWP‘, 10, 1 );
add_action( ‚wpuf_edit_post_after_update‘, ‚update_GEOmyWP‘, 10, 1 );
[/php]
[php]
function update_GEOmyWP( $post_id, $form_id ) {
// check the right FORM
if ( $form_id != 6463 ) {
return;
}
// make sure post ID exists.
if ( ! $post_id ) {
return;
}
// verify the updater function.
if ( ! function_exists( ‚gmw_update_post_location‘ ) ) {
return;
}
if ( isset( $_POST[‚rockspot_place‘] ) ) { // Aufnahmeort ist der Key des Feldes
list( $rs_address, $rs_lat, $rs_lng ) = explode( ‚||‘, $_POST[‚rockspot_place‘] );
list( $rs_street, $rs_place, $rs_country ) = explode( ‚,‘, $rs_address );
list( $rs_postcode, $rs_city ) = explode( ‚ ‚, trim( $rs_place ), 2 );
$location = array(
‚lat‘ => (float)$rs_lat,
‚lng‘ => (float)$rs_lng
);
if ( $rs_address ) {
update_post_meta( $post_id, ‚rockspot_address‘, trim( $rs_address ) );
}
if ( $rs_lat ) {
update_post_meta( $post_id, ‚rockspot_latitude‘, (float)$rs_lat );
}
if ( $rs_lng ) {
update_post_meta( $post_id, ‚rockspot_longitude‘, (float)$rs_lng );
}
if ( $rs_lat && $rs_lng ) {
update_post_meta( $post_id, ‚rockspot_latitude_longitude‘, (float)$rs_lat .‘,‘.(float)$rs_lng );
}
if ( $rs_street ) {
update_post_meta( $post_id, ‚rockspot_street‘, trim( $rs_street ) );
}
if ( $rs_city ) {
update_post_meta( $post_id, ‚rockspot_city‘, trim( $rs_city ) );
}
if ( $rs_place ) {
update_post_meta( $post_id, ‚rockspot_postcode_city‘, trim( $rs_place ) );
}
if ( $rs_postcode ) {
update_post_meta( $post_id, ‚rockspot_postcode‘, trim( $rs_postcode ) );
}
if ( $rs_country ) {
update_post_meta( $post_id, ‚rockspot_country‘, trim( $rs_country ) );
}
//run the udpate location function
gmw_update_post_location( $post_id, $location );
}
}
add_action( ‚wpuf_add_post_after_insert‘, ‚update_GEOmyWP‘, 10, 2 );
add_action( ‚wpuf_edit_post_after_update‘, ‚update_GEOmyWP‘, 10, 2 );
[/php]
[/themify_is_logged_in]