OK. I seem to have found a solution, so I’m gonna share it here:
First, I replaced the groups_screen_group_admin_delete_group with a slightly changed version where I call a custom function after this line:
`do_action( ‘groups_before_group_deleted’, $bp->groups->current_group->id );`
Remember to register this correctly! In my case:
`
remove_action( ‘bp_screens’, ‘groups_screen_group_admin_delete_group’ );
add_action( ‘bp_screens’, ‘myplugin_groups_screen_group_admin_delete_group’ );
`
where ‘myplugin_groups_screen_group_admin_delete_group’ is the name of the function.
The function I call makes use of groups_delete_group_forum_topic( $topic_id ) and bb_delete_forum( $forum_id ). This way, you delete the group and keep the db tidy!
`
$forum_id_array = $wpdb->get_results($wpdb->prepare(“
SELECT forum_id FROM wp_bb_forums
WHERE forum_id = (
SELECT meta_value
FROM wp_bp_groups_groupmeta
WHERE meta_key = ‘forum_id’
AND group_id = %s
) ;”
, $group_id));
$forum_id = $forum_id_array[0]->forum_id;
$topic_id_array = $wpdb->get_results($wpdb->prepare(“
SELECT topic_id FROM wp_bb_posts
WHERE forum_id = %s;”
, $forum_id));