I am using that for editing the post after it's created but I am using GF to create it because the client has a lot of specific wishes for the appearance of the front end form which was much more expedient to build in GF.
Does this code look like what one might want to use? It was posted by someone else but I haven't ever done this before so I couldn't follow it.
add_action('gform_pre_submission', 'wpq_register_added_meta_hook');
add_action('gform_post_submission', 'wpq_remove_added_meta_hook');
function wpq_register_added_meta_hook()
{
add_action('added_post_meta', 'wpq_added_post_meta', 10, 4);
}
function wpq_remove_added_meta_hook()
{
remove_action('added_post_meta', 'wpq_added_post_meta', 10, 4);
}
function wpq_added_post_meta($meta_id, $object_id, $meta_key, $meta_value)
{
global $wpdb;
if(!class_exists('Acf'))
return;
$query = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}acf_fields WHERE name = %s", $meta_key);
$acf_field = $wpdb->get_row($query);
if($acf_field)
{
$query = $wpdb->prepare("INSERT INTO {$wpdb->prefix}acf_values (field_id, value, post_id) VALUES (%d, %d, %d)", $acf_field->id, $meta_id, $object_id);
$wpdb->query($query);
}
}