Problem: I would like to establish relationships between two posts in a New Post Form.
Solution: It's not currently possible to manage M2M relationships in a Post Form, you must create a Relationship Form. To predefine the values, you can use the parent_item and child_item shortcode attributes in the cred_relationship_form shortcode:
[cred-relationship-form form='form-relationship-zoukers-events' parent_item='[wpv-post-id id="$current_page"]' child_item='[wpv-view name="get-zouker-id"]']
The View must return the correct Post ID for the child item, and must have no empty spaces in the loop editor markup:
[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-post-id]</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found][/wpv-no-items-found][wpv-layout-end]
Finally you must apply this custom filter that strips out additional markup from the View's results so it can be used as a shortcode attribute:
add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 ); function prefix_clean_view_output( $out, $id ) { $ids = array( 123 ); if ( in_array( $id, $ids )) { $start = strpos( $out, '<!-- wpv-loop-start -->' ); if ( $start !== false && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false ) { $start = $start + strlen( '<!-- wpv-loop-start -->' ); $out = substr( $out , $start ); $end = strrpos( $out, '<!-- wpv-loop-end -->' ); $out = substr( $out, 0, $end ); } else { $start = strpos( $out, '>' ); if ( $start !== false) { $out = substr( $out, $start + 1 ); $end = strpos( $out, '<' ); $out = trim(substr( $out, 0, $end )); } } } return $out; }
Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 9 replies, has 2 voices.
Last updated by 6 years, 3 months ago.
Assisted by: Christian Cox.