add_action('cred_save_data', 'prefix_cpt_cred_save_data_action', 10, 2);
function prefix_cpt_cred_save_data_action( $post_id, $form_data ){
if ($form_data['id']==62893){ //do the following code only if the CRED form ID is 62893, adjust this to your CRED form ID
if (!empty($_POST['post_parent'])){ //if parent is selected
$parent_id = $_POST['post_parent'];
add_post_meta($post_id, '_wpcf_belongs_parent-cpt-slug_id', $parent_id, true); //save the ID of the event as parent of the current post
// _wpcf_belongs_parent-cpt-slug_id, If your parent cpt slug is 'event' then it will be
// _wpcf_belongs_event_id
}
}
}
Please remember to carefully change the slugs and Form ID in above code.
Please open a new ticket for this 2nd issue (parametric search) and we would be happy to help. This will help other users with similar problems to find solutions when searching the forum, We do not handle multiple issues in the same ticket as per support policy. https://toolset.com/toolset-support-policy/
Thank you very much for your reply.
I'll try to describe the issue as clear as possible.
1- I have a cred form to create new product name, then I have other cred forms to edit that product and complete filling the designed information.
2- The product has a parent [Region] which is a child of [Country] where I plan to select it first in order to get only it's child [Regions] and select the parent [Region] for my product.
3- I'm setting some conditions to check before choosing which post field to display in place of %%NAME%% in the select menu
4- Will I be able to duplicate your 2 actions to apply on [Country] & [Region] parents? Or there is another way?
Thanks for explanations and making it clear. I am afraid this won't be doable using built-in options of Toolset. This may be possible using custom coding. The only hints I can think of are as below:
-- Here is ajax method to achieve this: hidden link
-- Here is another method using js:
We can display 2 dropdowns 1 for country and other for regions and hide regions dropdown using css for now. Here is an example of country dropdown option.
We can use country post slug as region option class i.e
<option value="region1" class="country1">country1 Region 1</option>
<option value="region2" class="country1">country1 Region 2</option>
<option value="region3" class="country2">country2 Region 1</option>
When user select country dropdown, we will get selected option value and show only those options using class selector in region dropdown and hide others.
In this way, user can only see specific country regions.
This falls into Custom coding & custom development and it is out of support policy (https://toolset.com/toolset-support-policy/). So we recommend to contact Toolset recommended service providers to further discuss the custom approach. We have some recommended list of service providers here if you would like to take a look: https://toolset.com/consultant/