Hi,
I'm using code here and it works great:
https://toolset.com/forums/topic/retain-checkbox-and-relationship-value-when-duplicate-post-on-front-end/
but how do I
1. duplicate the custom taxonomies
2. duplicate the relationships
One of the relationships is Track-Writer (M2M) with an intermediary field.
I understand if this is venturing into hiring a contractor territory.
Thank you!!
Hi Scott,
Thank you for contacting us and I'll be happy to assist.
Your understanding is correct and custom programming assistance is beyond the scope of the support that we provide. But we do our best to guide in the right direction, whenever possible.
1. If you'd like to duplicate the custom taxonomy terms attached to a post when it is submitted using the Toolset form, the following two steps will be involved:
a). First using a function attached to "cred_save_data" hook, (similar to https://toolset.com/forums/topic/retain-checkbox-and-relationship-value-when-duplicate-post-on-front-end/#post-948285 ), you'll get all the taxonomy terms attached to the post, through "get_the_terms" function:
https://developer.wordpress.org/reference/functions/get_the_terms/
b). To add the duplicates of each of those terms, you can then use "wp_set_post_terms" function:
https://codex.wordpress.org/Function_Reference/wp_set_post_terms
2. Likewise, it is possible to get information about the related posts and set new relationships, using the Toolset's "Post Relationship API":
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
a). First, you'll use "toolset_get_related_posts" function to get information about the existing related posts:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
b). And then to set new duplicated relationships, you'll use "toolset_connect_posts" function:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
For a more personalized assistance around custom code, you can consider hiring a professional from our list of certified consultants:
https://toolset.com/consultant/
I hope this helps.
regards,
Waqar
Hi Waqar,
Above my head unfortunately. Guess I'll have to hire someone.
Thank you for the info though!
Regards,
Scott.