I have a cpt called Wizard Sections and essentially what I’m trying to do is have a Cred form be populated by these cpt posts(into checkbox grouped by the category they are in), and then be able to output the submissions on the front-end for users. The form is working, now I'm not sure how to access the data and then output it into a template.
So far I’ve put a view into a Cred form that is outputting generic fields:
This is the View in the Cred form:
<wpv-loop>
<h3 style="clear: both;">[wpv-taxonomy-title]</h3>
[cred_generic_field field='[wpv-taxonomy-slug]' type='checkboxes' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[
[wpv-view name="website-wizard-view-1" wpvwizardelementcategory="[wpv-taxonomy-slug]"]]
}
[/cred_generic_field]
And the view in that view that is creating the options is:
<!-- wpv-loop-start --><wpv-loop>[wpv-item index=1]{"value":"[wpv-post-id]","label":"<img src=[types field='element-image' size='medium' url='true' resize='crop'][/types] >"}[wpv-item index=other] ,{"value":"[wpv-post-id]","label":"<img src=[types field='element-image' size='medium' url='true' resize='crop'][/types] >"}</wpv-loop><!-- wpv-loop-end -->
This is working and the form is rendering fine.
hidden link
But now I’m not sure how to access the submitted data so that I can put it into a template to show the user. I’ve created a custom field with the name faqs-element, the same name as one of the Cred fields, and I’ve tried this code, but it’s not working:
add_action('cred_save_data', 'custom_function',10,2);
function custom_function($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==1758)
{
$field= $_POST["faqs-element[]"];
update_post_meta($post_id, 'wpcf-faqs-element[]', $field);
}
}
Thanks for your assistance,
Tim