How to: When a bp Group created, automatically create a wp category [closed]

There is an action where you can hook in. It is called: ‘groups_created_group’. My idea is, that you hook into that and select the last group that was created. In database groups have a field called ‘date_created’. So just read the name of the last one and create your group out of that.

You have to write this in your functions.php file of your theme:

function createCatAfterGroup() {
  global $wpdb;
  $group = $wpdb->get_row("SELECT * FROM `wp_bp_groups` ORDER BY date_created DESC");
  wp_insert_term($group->name, 'category');
}
add_action('groups_created_group', 'createCatAfterGroup');