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.