This is related to a previous ticket... for reference:
https://toolset.com/forums/topic/cred-form-generic-field-not-saving-taxonomy-data-cred_save_data/#post-1405451
I've managed to use CRED edit form with cred_save_data action to save the generic field values (multi-select) into a taxonomy.
I am using View to populate the options for this from a separate custom post type (this is so I can keep everything dynamic)
When the data is saved into the taxonomy it is saving the slug and the term name as the value... which is a number... this makes it difficult in the admin side to see what's selected
- see image: hidden link
Function:
[code]
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==386143)
{
if (isset($_POST['test']))
{
wp_set_object_terms( $post_id, $_POST['test'], 'test', False );
}
}
}
[/code]
CRED Form:
[code]
[cred_generic_field type='multiselect' field='test' class='partner-service-industries']
{
"required":0,
"persist":1,
"default":[[wpv-view name="test-tax"]],
"options":[[wpv-view name="partner-industries-select"]]
}
[/cred_generic_field]
[/code]
View output from the shortcode above in options: [wpv-view name="partner-industries-select"]
[code]
{"value":"385119","label":"Aged Care"} ,{"value":"373524","label":"Fishery"} ,{"value":"373525","label":"Tobacco"}
[/code]
I am just not sure how to access and apply the label to the taxonomy using the function above 🙂
help?
thanks