Problem: I have a Form that creates child posts. When the child post is published, I would like to send an automatic email notification to an email address specified in the parent post's custom fields, but I cannot specify that field in the notification settings.
Solution: You can use some custom PHP code with the cred_notification_recipients API and the toolset_get_related_post API to query the parent post, get the custom field value, and add that email address to the recipients list programmatically:
Problem: I have an RFG set up on my site, and I would like to import content using a CSV import tool.
Solution: You should import each row of the RFG as though it is a new post, where the post type slug is identical to the RFG slug. The column format for the CSV file is dependent upon the CSV import tool you are using, but usually must include a column for specifying a parent post title or GUID with the column header format _toolset_associations_{RFG slug}. There should also probably be columns for post title, post author, and any custom fields you want to import for each row of the RFG. See the examples provided in this ticket for more information, and refer to the documentation for your preferred CSV import tool.
Problem:
We have two related CPTs - Resources & Resource Items (1 Resource - many Items). Each individual Item has a select field to indicate an associated language.
We present users with a Resources page where they can search on various aspects of Resources and would like to add the ability to search for Resources according to which languages they are associated with via their related Resource Items.
Solution:
Currently, Toolset does not allow to filter a custom post type by custom fields on a related post type. This feature is on our list and will be added in the future, but we still don't know when.
It is worth mentioning that this can be implemented with custom code. It will need custom code to build the filter and another custom code that can use the toolset_get_related_posts function and hook into the view's wpv_filter_query query filter.
Problem: I would like to use a cred-delete-post shortcode to allow my visitors to delete a post on the front-end of the site. This post may be the parent of one or more child posts. When the parent post is deleted, I would like to delete its attachments, and its child posts as well as their attachments.
Solution: Use the 'delete' action in the cred-delete-post shortcode, and customize the following code snippet to work with your post type slugs and post relationship slug.
function delete_post_children($post_id) {
global $wpdb;
$post_type = get_post_type( $post_id );
if ( $post_type == 'products' || $post_type == 'profile') {
$ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_parent = $post_id AND post_type = 'attachment'");
foreach ( $ids as $id ) {
wp_delete_attachment($id, true);
}
if(has_post_thumbnail( $post_id )) {
$tn_id = get_post_thumbnail_id( $post_id );
wp_delete_attachment($tn_id, true);
}
if( $post_type == 'profile' ) {
// in this case, we want to force-delete the child product posts as well
$profile_products = toolset_get_related_posts(
$post_id,
'profile-product',
[
'query_by_role' => 'parent',
'role_to_return' => 'child',
'limit' => 10000,
'orderby' => null,
]
);
foreach($profile_products as $profile_product ) {
wp_delete_post( $profile_product, true );
}
}
}
}
add_action('before_delete_post', 'delete_post_children');
Problem:
Hi, I have created a CPT "Inquiry" without title
This CPT is related to the CPT "Customers".
If I add an "inquiry" to a "customer", Toolset request anyway a title