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 13 topics - 721 through 733 (of 733 total)
Solution:
You can use CRED API hook cred_save_data in order to create child post and to establish relationship (connection) between your parent and child post type entry you need to add postmeta key.
When using Types posts relationships, the parent of a given type is stored in a field:
The issue here is that the user wanted to display additional fields in CRED based on a product category that the user selected.
Solution:
Regarding the conditionals, you would need to use the specialised CRED conditional field for this. This can be found by going to your CRED edit form and then clicking Add Generic Fields and clicking the conditional group.
However here is an example of what the output would be.
[cred_show_group if="($(product_cat) eq '46' )" mode='fade-slide']
My Cred Field code here
[/cred_show_group]
Problem:
The cred_delete_post_link shortcode can be used to delete posts from the front end, and works via ajax. It is currently not working (CRED 1.9.4)
Problem: I would like to use a CRED form to create a child post. When the post is saved, I would like to copy some custom fields from the parent and grandparent posts into the child post.
Solution: Use the CRED API cred_save_data method to automate this process. The link between parent / child posts is saved as a custom field on the child post with the name syntax "_wpcf_belongs_" + parent post type slug + "_id". Here is an example:
add_action('cred_save_data', 'save_parent_fields_to_child_fields',10,2);
function save_parent_fields_to_child_fields($post_id, $form_data) {
// update this to match your CRED form ID
if ($form_data['id'] == 12345)
{
// get the parent chosen in CRED form and use that to get parent and grandparent information
$parent_id = $_POST['_wpcf_belongs_werknemers_id'];
$parent_first_name = get_post_meta($parent_id, 'wpcf-voornaam-medewerker', true);
$parent_last_name = get_post_meta($parent_id, 'wpcf-achternaam-medewerker', true);
$grandparent_id = get_post_meta($parent_id, '_wpcf_belongs_werkgever_id', true);
$grandparent_first_name = get_post_meta($grandparent_id, 'wpcf-voornaam-werkgever', true);
$grandparent_last_name = get_post_meta($grandparent_id, 'wpcf-achternaam-werkgever', true);
// set the child post custom field values
update_post_meta($post_id, 'wpcf-voornaam-medewerker', $parent_first_name );
update_post_meta($post_id, 'wpcf-achternaam-medewerker', $parent_last_name );
update_post_meta($post_id, 'wpcf-voornaam-werkgever', $grandparent_first_name );
update_post_meta($post_id, 'wpcf-achternaam-werkgever', $grandparent_last_name );
}
}
Problem:
Client has a CRED form to publish child posts, and wants to include the form itself on the parent page. In that case how to set the parent post id in the CRED form?
Solution:
Use the wpv-post-id shortcode for the field value, like so:
[cred_field field='_wpcf_belongs_party_id' value='[wpv-post-id]' select_text='--- not set ---' class='form-control' output='bootstrap' ]
Problem: I am using the latest beta versions of Types and Views to preview M2M changes. How can I use these new relationships with CRED?
Solution: CRED is not quite ready for integration with these features. We started with Types and Views, and CRED will be later. Our developers are working on it, and we're aiming for a release at the end of this month (January 2018).