Do you have a time for when this could be done? I am using conditional shortcode at a lot of places on the site and this is kind of a show stopper for certain functionality.
Thank you. It seems to be visible in the right format. A few questions -
1) What was the reason for not working?
2) Why is the toolset_access shortcode not working?
However, it does not seem to do the job of connecting to the parent post (job) using the code below . You can also try it on your end.
The code is in toolset custom code -> link-m2m-relationship-between-jobs-and-project-prompts
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
add_action('cred_save_data', 'prowess_associate_multiple_related_posts_between_jobs_and_project_prompts',10,2);
function pprowess_associate_multiple_related_posts_between_jobs_and_project_prompts($post_id, $form_data) {
$forms = array( form-id1, form-id2 );
$relationship_1_slug = "job-to-project-prompt";
$ms_field_slug = "job-post";
if ( in_array( $form_data['id'], $forms ) ) // test if the form being submitted is in the list of form IDs we want to target
{
$ms_selections = $_POST[$ms_field_slug]; // the $_POST superglobal contains an array of the selected parent post IDs
foreach($ms_selections as $ms_selection) {
toolset_connect_posts( $relationship_1_slug, $ms_selection, $post_id); // while looping over selected parents, connect them to the new child post programmatically
}
}
}
?>
I am also not able to connect the parent and child post using the code mentioned earlier in the thread. The whole point of using the generic field is to create a relationship programmatically.
The code snippet in toolset custom code - link m2m relationship between jobs and project
Regarding the conditional i believe it had to do with the formatting and correct spacing.
2) Why is the toolset_access shortcode not working?
Based on the information from our 2nd tier team the access shortcode isn't meant to be used in a scenario like this hence why the access button isn't available on the form itself.
Regarding your hook I would suggest debugging a bit further to see if all your variables have the correct values.
I would perform a var_dump() on each of the variables to see what values are being passed. You should see the variable dump on the page when the form gets submitted.