Hi
i use cred so that visitors can create a new product that is still in the same category
its a way to prepopulate this category for the backoffice?
Thanks
Guyk
Dear Guyk,
I suggest you try with CRED action hook cred_save_data, apply a CRED API cred_save_data to this specific CRED Form and use WordPress API to update the Post Taxonomy with something you hard-coded.
More help:
cred_save_data
This hook allows doing a custom action when post data is saved to database.
https://toolset.com/documentation/user-guides/cred-api/
https://codex.wordpress.org/Function_Reference/wp_set_post_terms
https://codex.wordpress.org/Function_Reference/wp_set_object_terms
Hi
i see this three 'my_custom_field'
my category is this one
taxonomy=product_cat&tag_ID=28
Should I put
'taxonomy' in first
'product_cat' in second
'28' in third
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']==557)
{
if (isset($_POST['taxonomy']))
{
// add it to saved post meta
add_post_meta($post_id, '__product_cat', $_POST['28'], true);
}
}
}
Thanks
Guyk
Since it is a custom PHP codes problem, please duplicate same problem in a test site, and fill below private detail box with login details and ftp access, also point out the problem page URL and CRED form URL, and where I can edit your PHP codes, I need a live website to test and debug, thanks