Replies: 0
Is it possible to use this plugin to map to a custom post type that is
'public' => false,
'show_ui' => true,
It isn’t showing up as a drop-down option under Existing Post (Post Type) and I’ve tried adding filters. I can’t seem to get the filters to work on a regular post, but here’s what I was trying for my custom post type named resources
.
add_action( 'cf7_2_post_save-resources', 'cf7_to_resources',10,3);
function cf7_to_resources($cf7_key, $submitted_data, $submitted_files){
if('my-resource-form' != $cf7_key){
return;
}
else{
$title = $submitted_data['your-name'];
$content = $submitted_data['your-message'];
$post_args = array(
'post_type' => 'resources',
'post_status' => 'draft',
'post_title' => $title,
'post_content' => $content,
);
$post_id = wp_insert_post($post_args);
update_post_meta($post_id, 'your_email', $email);
}
}
add_filter( 'cf7_2_post_load-resources', 'cf7_function_resources',10,5);
function cf7_function_resources( $field_value_pairs, $cf7_key, $form_fields, $form_field_options, $cf7_post_id){
foreach($form_fields as $field=>$type){
$field_value_pairs[$field] = '';//load your value
}
$field_value_pairs['map_post_id'] = $post_id;
return $field_value_pairs;
}