Hi,
I'm trying to save a repeating field group using generic fields in a User Form to a cpt.
I have a repeating field group called Coach Education with has 3 fields (Coach School Name, Coach Degree, Coach Year Graduated). And I have a User Form in the link below that creates a new user and a Coach cpt. The form also uses generic fields to create populate the Coach cpt custom fields.
hidden link
I've tried to use Generic fields to populate this repeating field group but it is not working. Is this a limitation in toolset?
In my form I have these 3 generic fields:
<label>School Name</label>
[cred_generic_field type='textfield' field='coach-school-name']
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]
</div>
<div class="col-sm-5 formspacer ">
<label>Degree</label>
[cred_generic_field type='textfield' field='coach-school-degree']
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]
</div>
<div class="col-sm-2 formspacer ">
<label>Year Graduated</label>
[cred_generic_field type='numeric' field='coach-year-graduated']
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]
</div>
And this is what I have in functions.php:
add_action('cred_save_data', 'save_coach_cpt_init',10,2);
function save_coach_cpt_init($post_id, $form_data) {
if ($form_data['id']==127)
{
$post_id = wp_insert_post( array(
'post_status' => 'publish',
'post_type' => 'coach',
'post_author' => $post_id,
'post_title' => $_POST['first_name'].' '.$_POST['last_name'],
'post_content' => ''
) );
update_post_meta($post_id, 'wpcf-coach-first-name', $_POST['first_name']);
update_post_meta($post_id, 'wpcf-coach-last-name', $_POST['last_name']);
update_post_meta($post_id, 'wpcf-coach-email', $_POST['user_email']);
update_post_meta($post_id, 'wpcf-coach-street-address', $_POST['coach-street-address']);
update_post_meta($post_id, 'wpcf-coach-phone', $_POST['coach-phone']);
update_post_meta($post_id, 'wpcf-coach-website', $_POST['coach-website']);
update_post_meta($post_id, 'wpcf-coach-zip-code', $_POST['coach-zip-code']);
update_post_meta($post_id, 'wpcf-coach-description', $_POST['coach-description']);
update_post_meta($post_id, 'wpcf-coach-gender', $_POST['coach-gender']);
update_post_meta($post_id, 'wpcf-coach-video', $_POST['coach-video']);
update_post_meta($post_id, 'wpcf-coach-specialties', $_POST['coach-specialties']);
update_post_meta($post_id, 'wpcf-years-practicing', $_POST['years-practicing']);
update_post_meta($post_id, 'wpcf-coach-photo', $_POST['coach-photo']);
update_post_meta($post_id, 'wpcf-coaching-certificate-image', $_POST['coaching-certificate-image']);
update_post_meta($post_id, 'wpcf-coach-certificate', $_POST['coach-certificate']);
update_post_meta($post_id, 'wpcf-training-qualifications-experience', $_POST['training-qualifications-experience']);
update_post_meta($post_id, 'wpcf-coach-street-address', $_POST['coach-street-address']);
update_post_meta($post_id, 'wpcf-coach-state', $_POST['coach-state']);
update_post_meta($post_id, 'wpcf-coach-city', $_POST['coach-city']);
update_post_meta($post_id, 'wpcf-coach-linkedin-profile', $_POST['coach-linkedin-profile']);
update_post_meta($post_id, 'wpcf-coach-education', $_POST['coach-education']);
update_post_meta($post_id, 'wpcf-coach-fee', $_POST['coach-fee']);
update_post_meta($post_id, 'wpcf-coach-school-name', $_POST['coach-school-name']);
update_post_meta($post_id, 'wpcf-coach-school-degree', $_POST['coach-school-degree']);
update_post_meta($post_id, 'wpcf-coach-year-graduated', $_POST['coach-year-graduated']);
wp_set_post_terms( $post_id, $_POST['coach-specialties'], 'coach-specialty');
}
}
Thanks,
Tim