This topic contains 6 reply and 3 voices, and was last updated by onafets 6 years, 2 months ago
Viewing 6 Posts - 1 through 6 (of 6 total)
Author Posts
April 19, 2013 at 7:35 am 2517
onafets Dear Tarek, Thank you for this pro version. I used the free one since a year and it was very useful. Currently I'm working on a migration between WP User Frontend free version to the pro version since yesterday. I discovered that your Google Maps field in the form generator does not saves the address field, it only saves the lat/long data. Which is a problem since I used both. I tried to add an action hook in the form (name: 'wpuf_pronamic_location'). The functions below worked well with the free version. With the pro version the additional fields are displayed in the form, but the custom fields are not saved. Could you please have a look and help me? Thanks a lot! //////// PRONAMIC GOOGLE MAPS IN FRONT END ////////// add_action('wpuf_pronamic_location', 'wpuf_pronamic_location', 10, 3 ); function wpuf_pronamic_location( $post_id ) { print_r(pronamic_get_google_maps_meta()); // delete to hide data checking $pgm_map_type = ( $post != null ) ? get_post_meta( $post_id, '_pronamic_google_maps_map_type', true ) : ''; $pgm_zoom = ( $post != null ) ? get_post_meta( $post_id, '_pronamic_google_maps_zoom', true ) : ''; $pgm_address = ( $post != null ) ? get_post_meta( $post_id, '_pronamic_google_maps_address', true ) : ''; $pgm_latitude = ( $post != null ) ? get_post_meta( $post_id, '_pronamic_google_maps_latitude', true ) : ''; $pgm_longitude = ( $post != null ) ? get_post_meta( $post_id, '_pronamic_google_maps_longitude', true ) : ''; wp_nonce_field('save-post', Pronamic_Google_Maps_Maps::NONCE_NAME); ?&gt; <div id="pronamic-google-maps-meta-box"> <ul> <li><input id="pgm-map-type-field" type="hidden" name="&lt;?php echo Pronamic_Google_Maps_Post::META_KEY_MAP_TYPE; ?&gt;" value="&lt;?php echo esc_attr( $pgm_map_type ); ?&gt;" /> <input id="pgm-zoom-field" type="hidden" name="&lt;?php echo Pronamic_Google_Maps_Post::META_KEY_ZOOM; ?&gt;" value="&lt;?php echo esc_attr( $pgm_zoom ); ?&gt;" /> <input id="pgm-active-field" type="hidden" name="&lt;?php echo Pronamic_Google_Maps_Post::META_KEY_ACTIVE; ?&gt;" value="true" /><label for="pgm-address-field">Address <span class="required">*</span></label> <textarea class="requiredField" id="pgm-address-field" cols="40" name="&lt;?php echo Pronamic_Google_Maps_Post::META_KEY_ADDRESS; ?&gt;" rows="2">&lt;?php echo esc_attr( $pgm_address ); ?&gt;</textarea> <p class="description">Please type the address then click on "Geocode ↓" to show the location on the map.</p> <p class="description">Or you can drag the marker on the map then click on "Reverse Geocode ↑" to update the address.</p> </li> <li><input class="button" id="pgm-geocode-button" type="button" name="pgm_geocode" value="&lt;?php _e('Geocode ↓', 'pronamic_google_maps'); ?&gt;" /><input class="button" id="pgm-reverse-geocode-button" type="button" name="pgm_reverse_geocode" value="&lt;?php echo _e('Reverse Geocode ↑', 'pronamic_google_maps'); ?&gt;" /></li> <li><label for="pgm-lat-field">Latitude</label> <input id="pgm-lat-field" style="width: 200px;" type="text" name="&lt;?php echo Pronamic_Google_Maps_Post::META_KEY_LATITUDE; ?&gt;" value="&lt;?php echo esc_attr($pgm_latitude); ?&gt;" /> °</li> <li><label for="pgm-lng-field">Longitude</label> <input id="pgm-lng-field" style="width: 200px;" type="text" name="&lt;?php echo Pronamic_Google_Maps_Post::META_KEY_LONGITUDE; ?&gt;" value="&lt;?php echo esc_attr($pgm_longitude); ?&gt;" /> °</li> <li><label for="pgm-canvas">Location result</label> <div id="pgm-canvas" style="width: 600px; height: 350px; margin-left: 140px; border: 1px solid white;"></div> <p class="description">Tip: Change the zoom level and map type to your own wishes.</p> </li> </ul> </div> <!--?php </p--> } /** * Add the gg maps data after creation/edition * * * @param int $post_id the post id */ function wpufe_add_anecdote_gmaps( $post_id ) { update_post_meta( $post_id, '_pronamic_google_maps_map_type', $_POST['_pronamic_google_maps_map_type'] ); update_post_meta( $post_id, '_pronamic_google_maps_zoom', $_POST['_pronamic_google_maps_zoom'] ); update_post_meta( $post_id, '_pronamic_google_maps_active', $_POST['_pronamic_google_maps_active'] ); update_post_meta( $post_id, '_pronamic_google_maps_address', $_POST['_pronamic_google_maps_address'] ); update_post_meta( $post_id, '_pronamic_google_maps_latitude', $_POST['_pronamic_google_maps_latitude'] ); update_post_meta( $post_id, '_pronamic_google_maps_longitude', $_POST['_pronamic_google_maps_longitude'] ); } add_action( 'wpuf_add_post_after_insert', 'wpufe_add_anecdote_gmaps' ); add_action( 'wpuf_edit_post_after_update', 'wpufe_add_anecdote_gmaps' );
April 19, 2013 at 8:14 am 2526
Tareq Hasan Tareq Hasan

Hello Jeremy, take a look at the plugin integration I did for pronamic. The name of that address finder field is “address”, so adding this `update_post_meta( $post_id, ‘address’, $_POST[‘address’] );` to that code (mine) should save the address. So the map custom field meta key should be not “address”, otherwise it won’t work.

April 19, 2013 at 10:47 am 2537
jeremy.debost jeremy.debost

But this code is for saving the data on the new posts.

My other concern is that your Google Maps box will not display the pronamic data input in the previously created posts and I can’t get that through your address finder. Also I need to use some advanced functions of Pronamic GG Maps like the geocode/reverse geocode buttons.The data is saved (I can see it in the back end form) but it is not displayed on the front end form when you reload it. Is there a problem with the get_post_meta() functions here?Thanks a lot for your help, I’m really stuck with this.

April 19, 2013 at 11:03 am 2540
Tareq Hasan Tareq Hasan

I think you can use the code from your first post. You’ve a small problem in the function argument. Change the function parameter: `function wpuf_pronamic_location( $form_id, $post_id ) {`. The `$post_id` will be the second parameter.

April 19, 2013 at 11:27 am 2542
jeremy.debost jeremy.debost

It’s working like a charm. Thank you so much for your time Tareq. Apparently I was not careful enough when I read your developer documentation.

April 19, 2013 at 11:33 am 2544
Tareq Hasan Tareq Hasan

Cool 😀

June 1, 2013 at 2:24 pm 4404
onafets onafets

jeremy.debost

can you please share the whole snippet?
thank you in advance

Viewing 6 Posts - 1 through 6 (of 6 total)