Skip Navigation

[Resolved] prepopulate product category in cred

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 8 years ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by kayser 8 years ago.

Assisted by: Luo Yang.

Author
Posts
#455698

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

#456005

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

#456023

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

#456612

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

The forum ‘Types Community Support’ is closed to new topics and replies.