Parent Post Type: Trip
Child Post Type: Traveler
New Travelers are created using a URL string, like website/join-trip/?parent_trip_id=569
Both post types have a "Group" taxonomy.
I want to duplicate that taxonomy from the parent into the child (on that cred form). I've tried a number of things that don't work, like:
[cred_field field='group' force_type='taxonomy' output='bootstrap' display='select' single_select='true' value='[wpv-post-taxonomy type="group" format="id" item="@trip_attendee.parent"]']
When I use: Group: [wpv-post-taxonomy type="group" format="name" item="[wpv-search-term param="parent_trip_id"]"]
it spits out the correct group, but how can I populate the dropdown correctly so that when the user submits, it'll have the correct group selected?
Do I need to embed the cred form in a view to get it to work? That's something that was required for some of my older issues.
Hello,
The shortcode "value" attribute of shortcode [cred_field] won't work for taxonomy field, see our document:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field
value. Optional
...
Does not apply to all field types, e.g. taxonomies.
You might consider custom codes, for example, after user submit the child post form, use action hook cred_save_data to trigger a custom PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
In this PHP function, get the related parent post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
Get the parent post taxonomy "group" setting:
https://developer.wordpress.org/reference/functions/wp_get_object_terms/
Setup the child post taxonomy "group" setting:
https://developer.wordpress.org/reference/functions/wp_set_object_terms/
For your reference.