I think you’d have to switch blog before you can wp_insert_term().
To switch blogs, one uses switch_to_blog($xx) where $xx is the id of the other blog. You can read about it here: http://codex.wordpress.org/WPMU_Functions/switch_to_blog
Warning: I’ve only ever done that to pull information from a specific site. Things might come in your way, when trying to insert data via this method. I’d say, give it a try.
Many thanks @sandra l***.
Did try that but was unable to continue as the hook i was using was ‘groups_created_group’ in the group formation panel of buddypress and it stopped the process before restore blog came in to play.
However i am looking at a mysql route and appear to have found a kind of “round the houses” solution
$txx = $wpdb->get_var("SELECT * FROM
wp_xx_terms` ORDER BY term_id DESC”);
$xp = 1;
$tid = $txx + $xp;
$wpdb->insert(wp_xx_terms, array (‘term_id’=> NULL, ‘name’=> $xgroup, ‘slug’=> $slug, ‘term_group’=> ‘0’));
$wpdb->insert(wp_xx_term_taxonomy, array (‘term_taxonomy_id’=> NULL,’term_id’=> $tid, ‘taxonomy’=> ‘category’, ‘description’=> ‘community group’, ‘parent’=> ‘0’,’count’=> ‘0’,));`
so I am marking this as resolved.
Some of the single/back quotes are missing in the above e.g. on wp_xx_terms.
Cheers.