although it looks like your location is saved on wp_posts it might not be saving on wp_em_locations tables ?
2 problems with your approach for our purposes
we use post custom fields for the info similar to the names in wp_em_locations e.g. _location_town (note the preceding _ )
also, we save an additional record in wp_em_locations which is used for searching and linking events with locations.
Thread Starter
adzay
(@adzay)
Hi,
Further investigation made me find the reason for this. In Events-manager.js there is a script at around line 540 .
if( jQuery( "#em-location-data input#location-name" ).length > 0 ){
jQuery( "#em-location-data input#location-name" ).autocomplete({
source: EM.locationajaxurl,
minLength: 2,
focusout: function( event, ui ){
jQuery("input#location-id" ).val( ui.item.value );
return false;
},
select: function( event, ui ){
jQuery("input#location-id" ).val(ui.item.id).trigger('focusout');
As you can see from this line I changed the triggers from ‘.change’ to ‘focusout’ so that the function runs when the user clicks away from the field.
Then I combined it with this that I placed in my functions.php
function Select_location_field() {
echo "<script>jQuery(document).ready(function(){
jQuery('#location-address').on( 'focus', function( event ) {
console.log('debug: on change fired!');
});
jQuery('#location-address').focus();
});</script>";
}
add_action( 'admin_head-post.php', 'Select_location_field' );
that function automatically highlights the text in #location-address field as soon as when the edit location admin screen is opened. When I click away the script runs and the map generates. Then of course I press save.
Im wondering is there a way to make that script run automatically when a post is created outside of the admin screen?
Thread Starter
adzay
(@adzay)
I understand that using your built in form is the easier option, but I am using this plugin because it allows me to easily import posts from an excel/CSV file ( my file currently has 100 rows so far). It is also easier to customize.
Taking that into mind, one Caveat to that is that I have to open a post in the edit location screen, click out from the highlighted field so that the script runs, save and then move to the next.
In my case you can imagine it will be time consuming because I have 100 posts ( still increasing)
Thread Starter
adzay
(@adzay)
Sorry for the large amount of replies, honestly i am not trying to bump this up.
On the website for the form plugin there is a action hook that runs a function after the form is made. http://formidablepro.com/knowledgebase/action-hooks/frm_after_create_entry/#kb-insert-form-data-into-second-database-table
Each item_meta represents a field in the form. If I was to use this filter to insrt the values directly into the wp_em_locations, will the latitude/longitude calculation and map generation activate?
add_action('frm_after_create_entry', 'copy_into_my_table', 20, 2);
function copy_into_my_table($entry_id, $form_id){
if($form_id == 4){ //change 4 to the form id of the form to copy
global $wpdb;
$values = array('col_name1' => $_POST['item_meta'][25], 'col_name2' => $_POST['item_meta'][26]);
//replace 25 and 26 with the field ids of the Formidable form. Change col_name to the column names in your table
$wpdb->insert('table_name', $values);
}
}
If you cannot help me with this ( because it is another plugin) can you ignore this post in particular and help me with question above?
Thanks 🙂
there’s quite a lot of investigating involved here… you probably need to consider finding a developer to help you with this. sorry!