Store created post ID in a Formidable Form entry field

Labels

This Discussion is public

Notifications

Hi folks,

I understand how to store "the entry ID of the form submission that created a new post, in one of the post's custom fields," but I don't understand how to go the other way.

We have a lot of forms that do different things on the site. For example, only a certain group of forms creates records. To get the form submission entry ID into the created post (specifically, into a field called "form_entry_created_by", I do the following:

add_filter( 'frm_new_post', 'frm_save_entry_id_to_custom_field', 10, 2 );
function frm_save_entry_id_to_custom_field( $post, $args ) {
  $form_key = FrmForm::get_key_by_id( $args['form']->id );
  $special_forms = array(
    'm_form_new_member', 
    's_band_aud_form', 
    's_choir_aud_form',
    's_choir_rec_form',
    's_jib_app_form',
  );
  if ( in_array( $form_key, $special_forms ) ) {
    $post['post_custom']['form_entry_created_by'] = $args['entry']->id;
  }
return $post;
}

But I don't know how to do the reverse - set the newly created post's post ID into a custom field in the Formidable Forms form submission/entry.

It seems like it might actually be easy (maybe easier than what I'm attempting) because Formidable Forms does seem to maintain a link between the created post and the form submission. When I delete theĀ form submission that created the post, the post also disappears; and a link to the created post also appears in the Edit screen for the form entry.

Is there a method to "surface" the newly created post ID and drop it into a Formidable Form entry field? Thanks!

Formidable stores the post_id in the wp_frm_items table. You can retrieve the post_id using custom SQL. See this: https://gist.github.com/DarrylErentzen/9652556

Reply to this Discussion