Automap creation when populating address field programmatically

Home Forums MapPress Support Automap creation when populating address field programmatically

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10411
    BradSiegfried
    Participant

      Hi Chris,

      I’m creating posts by using Formidable Pro.  So far, so good except that when the post is created, the address custom field is correctly populated but the automap creation does not occur.  If I edit and save the post from the WordPress UI, the automap is created.

      I’m guessing that there is some call that happens when posts are saved from the UI but that isn’t happening when posts are saved via Formidable Pro.  Can you point me in the right direction here?

      Thanks.

      Brad

      #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);
        #10415
        BradSiegfried
        Participant

          Hi Chris,

          I tested that code and it works great. (I put it into my generic site utilities plugin instead of functions.php; no worries about theme updates that way.)

          Thanks once again for the outstanding support.

          Brad

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.