CRED plugin allows you to build forms that create child posts and set parents for these posts, supporting the parent-child relationship functionality from Types plugin.
When you ask for help or report issues, make sure to tell us the structure of your content and the relationship between the content types.
Viewing 15 topics - 271 through 285 (of 308 total)
Problem:
1. I have two custom post types, "Booking" and "Accommodation", in a one-to-many relationship where many Bookings can be connected to one Accommodation. I also have a Form that creates Booking posts, and I would like hose posts to be connected to the proper parent Accommodation automatically.
2. I need to email the booking to either the admin email if no agent is assigned to that accommodation, or to the agent if there is assigned one. For Agents I have another CPT (Ugynokok) which is connected to the accommodation.
Solution:
1. Add a relationship field to the new Booking Form, and set the value to be the ID of the page being displayed. The syntax will look something like this:
<div style="display:none;">
<div class="form-group">
<label>Accommodation Bookings</label>
[cred_field field='@accommodation-booking.parent' class='form-control' output='bootstrap' select_text='--- not set ---' value='[wpv-post-id item="$current_page"]']
</div>
</div>
2. This type of conditional logic isn't built in to the email notification system, but you can set up something like this using the PHP APIs. We have cred_notification_recipients to modify the notification recipients on-the-fly and the Post Relationships API toolset_get_related_posts to help you determine if there is an associated Agent.
Problem: I have a Form that creates posts. I would like to automatically link the new post to another post using post relationships.
Solution: Create a link to the new post Form that includes the existing post ID in a URL parameter. Then use a generic field in the new post Form to capture that post ID and pass it into a cred_save_data callback. Use the Post Relationships API to link the two posts.
Problem: I would like to create a View of RFG that are not assigned to any parent post.
Solution: Use a View of RFG with no post relationship filter, and add a conditional like this:
[wpv-conditional if="( '[wpv-post-id item="@rfg-slug.parent"]' eq '' )"]
RFG [wpv-post-title], ID: [wpv-post-id] is an orphan!<br />
You could add an edit post link here, if you'd like.
[/wpv-conditional]
Problem: I have a Form that creates Job posts. That form is set to redirect to another page that contains another Form that creates RFGs for that Job post. I would like to make sure these RFGs are automatically associated with the correct Job post.
Solution: You'll have to use a bit of custom code to add a URL parameter to the first Form's redirect.
Problem:
A form to add repeatable field groups includes a selector to specify which post they belong to. How to pre-select that post?
Solution:
Repeatable field groups are implemented as child posts of the post to which the fields belong, and the normal workflow for adding child posts where the parent is predefined is described in the linked documentation.
In this case, the client was including the forms to add repeatable field groups directly in the output of a View, in which case the parent post could be specified by using the wpv-post-id shortcode to provide the default value for the selector.