Based on my previous support request, I am trying to do the same thing with another form & post type.
I have duplicated the custom code as below but it isn't working. Any idea where I have gone wrong?
I have updated the function name, form ID and the toolset_connect_posts name
thanks
add_action('cred_save_data', 'func_connect_profile_with_report',10,2);
function func_connect_profile_with_report($post_id, $form_data){
You will perhaps need to exit the code while it's running to see what happens.
Can you add this line below and then run the form to see what gets dumped out on the page.
Hi Shane
I'm not sure what the 'fields'=>"ids" argument is for, I have just reused the same snippet supplied in my previous support request to achieve the same thing (with different posts).
If I add this to the code:
var_dump($found_profile[0]);
var_dump($post_id);
I get the result of int(1512) int(15835) which is the Profile ID and the Post ID so I'm guessing something is wrong with the toolset_connect_posts command. I have created the relationship with the slug of profile-country-report, the only difference of it compared to the one I had for the previous support request, is that this one is a one-to-one relationship not a one-to-many. Should that make any difference?
The reason why it wasn't working was because of this error message.
"The element Britain has already the maximum allowed amount of associations (1) as in the relationship Profiles Country Reports."
It should be working now. What I had to do was to clear up some of the trash posts that were connected to the britain user.
So in order to allow britain to connect to a country report relationship you will need to delete my "Final test" post and then remove it from the trash as well.
Thanks, I can't believe it was such an obvious thing, once you know.
Can I ask though where did you get that error message from, I never saw it anywhere.