Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

example: a user creates a group "cats" automatically a category "cats" would be created with the slug "cats" or a user creates a group "Fat Cats" automatically a category "Fat Cats" would be created with the slug fat-cats. I see there is a function wp_create_category : However,to be frank, i'm lost.

Have tried, with adding this near end (line310) of child-theme/groups/create.php but no dice

Any help or ideas really welcome

share|improve this question

closed as off-topic by toscho Aug 2 at 20:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 0 down vote accepted

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');
share|improve this answer
    
thanks BUT tested and creating group stops at first template i.e Clicking Create Group and continue brings up blank screen what about using bp_get_new_group_name(); I see that in bp-groups-template.php . Your idea though is fantastic outside the box thinking! could you tweak it a little! i can try things but not fully sure what i'm doing! –  Valentine Cosgrave Dec 7 '12 at 10:03
    
No error? Take a look in your database, maybe the table has a different name. Can't be a big problem. In my mind it should work. :) –  movsky Dec 7 '12 at 10:06
    
I got it working, i updated my post above with the correct code. You need to use wp_insert_term() instead. –  movsky Dec 7 '12 at 10:15
    
bp_get_new_group_name() seems to give you the group you created before the one you actually want to have. Don't really know why. –  movsky Dec 7 '12 at 10:18
    
tried again. the group 'movsky' IS being created and recorded in the database wp_bp_groups. The category is NOT being produced in wp_terms and clicking Create group and continue brings the white wall of death! pity, something tiny is holding it up! –  Valentine Cosgrave Dec 7 '12 at 10:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.