Reply To: Automap creation when populating address field programmatically

Home Forums MapPress Support Automap creation when populating address field programmatically Reply To: Automap creation when populating address field programmatically

#10414
Chris
Keymaster

    Hi Brad,

    Normally MapPress updates its maps when the ‘save_post’ action is triggered.  This happens when a post is saved or published.

    Formidable is probably updating the post’s custom fields after the ‘save_post’ action is triggered – so the fields are still blank when MapPress checks.

    What’s needed is an action or fitler that happens after the post is created and the custom fields are updated.

    I took a quick look at the Formidable forums and I think this code will work (add it to your functions.php):

    function update_maps ($entry_id, $form_id) {
       if($form_id == 17) {        // Replace with your form ID
        //get ID of post to be created
        global $frmdb;
        $post_id = $frmdb->get_var( $frmdb->entries, array('id' => $entry_id), 'post_id' );
        // Update the map for that post
        do_action('mappress_update_meta', $post_id);
      }
    }
    
    add_filter('frm_after_create_entry', 'update_maps', 50, 2);