Problem:
How to set default categories using Toolset Forms?
Solution:
Add the code below:
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"]==7220) {
$category_ids = array(82); // replace your category ID
wp_set_object_terms( $post_id, $category_ids, 'category');
}
if ($form_data["id"]==7232) {
$category_ids = array(83); // replace your category ID
wp_set_object_terms( $post_id, $category_ids, 'category');
}
}
Change the Form IDs and Category IDs with the IDs you have on your website.
Relevant Documentation:
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
This topic contains 2 replies, has 2 voices.
Last updated by 3 years, 1 month ago.
Assisted by: Christopher Amirian.