Is it possible to use custom code to automatically add a new post to a Toolset Access Post Group?
For details, I have a post type called "Resources" and another post type called "Events." Events are children of positions (one position can have multiple events). Each resource will be assigned to its own post group (never will it be in two post groups). When creating a new event, I would like some code that would automatically add the Event to the same post group as the Resource. Can you tell me if this is possible? Thanks in advance!
That wasn't exactly what I was looking for but it did get me pointed in the right direction. Below please find code I ended up developing that seems to work perfectly:
add_action( 'toolset_association_created', 'croydon_assign_to_post_group', 10, 5 );
function croydon_assign_to_post_group( $association_slug, $parent_id, $child_id, $intermediary_id, $association_id ) {
// retrieve toolset post group
$post_group = get_post_meta($parent_id, '_wpcf_access_group', true);
// remove pre-existing post group
$toolset_remove_post_group = delete_post_meta($child_id, '_wpcf_access_group');
// assign to post group
if ($post_group != false) {
add_post_meta($child_id, '_wpcf_access_group', $post_group);
}
}
Thanks again for the continued support.
- Aaron
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.