[themify_is_logged_in]
#################### ACF Google Maps API ################################## function my_acf_init() { acf_update_setting('google_api_key', 'AIzaSyA701XV1EOlkeSDgmjxV7fRRQ-QDKx2mfA'); } add_action('acf/init', 'my_acf_init'); #################### ACF Update Custom Field when Save Post ############### function my_copy_date_filter( $post_id ) { $post_type = get_post_type( $post_id ); if ( $post_type != 'spot' ) { return; } $location = get_field( 'spot_location', $post_id ); if( $location[ 'lat' ] && $location[ 'lng' ] ) { update_field( 'spot_lat_lng', $location[ 'lat' ].','.$location[ 'lng' ], $post_id ); } if( $location[ 'state' ] ) { update_field( 'new_spot_state', $location[ 'state' ], $post_id ); } if( $location[ 'city' ] ) { update_field( 'new_spot_city', $location[ 'city' ], $post_id ); } } add_filter( 'acf/save_post', 'my_copy_date_filter', 20 );
#################### ACF Update Custom Field when Save Post ############### function my_copy_date_filter( $post_id ) { $post_type = get_post_type( $post_id ); if ( $post_type != 'spot' ) { return; } $location = get_field( 'spot_location', $post_id ); if( $location[ 'lat' ] && $location[ 'lng' ] ) { update_post_meta( $post_id, 'spot_coordinates', $location[ 'lat' ].','.$location[ 'lng' ] ); } if( $location[ 'address' ] ) { update_post_meta( $post_id, 'spot_address', $location[ 'address' ] ); } if( $location[ 'state' ] ) { wp_set_object_terms($post_id, $location[ 'state' ], 'bundesland', false); } if( $location[ 'city' ] ) { wp_set_object_terms($post_id, $location[ 'city' ], 'ort', false); } if( $location[ 'post_code' ] ) { wp_set_object_terms($post_id, $location[ 'post_code' ], 'postleitzahl', false); } } add_filter( 'acf/save_post', 'my_copy_date_filter', 20 );
#################### WPUF Map to Custom Fields and Taxonomies ############### function my_copy_date_filter_wpuf( $post_id, $form_id ) { if ( $form_id != 619 ) { return; } if ( isset( $_POST['spot_location'] ) ) { $location = get_post_meta( $post_id, 'spot_location', true); if( $location[ 'lat' ] && $location[ 'lng' ] ) { update_post_meta( $post_id, 'spot_coordinates', $location[ 'lat' ].','.$location[ 'lng' ] ); } if( $location[ 'address' ] ) { update_post_meta( $post_id, 'spot_address', $location[ 'address' ] ); } if( $location[ 'state' ] ) { wp_set_object_terms($post_id, $location[ 'state' ], 'bundesland', false); } if( $location[ 'city' ] ) { wp_set_object_terms($post_id, $location[ 'city' ], 'ort', false); } if( $location[ 'post_code' ] ) { wp_set_object_terms($post_id, $location[ 'post_code' ], 'postleitzahl', false); } } } add_action( 'wpuf_add_post_after_insert', 'my_copy_date_filter_wpuf',10, 2 ); add_action( 'wpuf_edit_post_after_update', 'my_copy_date_filter_wpuf',10, 2 );
[/themify_is_logged_in]