Closed (duplicate)
Project:
OG Forum D7
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
4 Jan 2013 at 16:57 UTC
Updated:
30 Jan 2015 at 18:41 UTC
Jump to comment: Most recent
There should probably be an option to create a new forum when adding a new group.
I did this quickly for my needs in a custom module as so:
/**
* Implements hook_node_insert().
* Create a forum for each organic group created.
*/
function CUSTOM_node_insert($node) {
if ($node->type == 'MY_GROUP_TYPE') {
$term = new stdClass();
$term->vid = MY_FORUM_VOCABULARY_ID;
$term->name = $node->title . ' Forum';
taxonomy_term_save($term);
$values = array(
'entity_type' => 'taxonomy_term',
'entity' => $term->tid,
);
og_group('node', $node->nid, $values);
}
}
Comments
Comment #1
melchior commentedhey, thx for the code!
what's the best way to get the related tid on a node view? I tried the following code but it seems to be really inconvenient..
Comment #2
melchior commenteddouble post, sorry
Comment #3
jienckebd commentedIn my case, this is the only taxonomy term I have associated with an organic group so this query works for me:
I use it in hook_node_delete() along with the above code to delete taxonomy terms as my groups are deleted.
Comment #4
vegantriathleteI'm thinking it might make more sense to create a Container for the group instead of a forum.
Edit: Taking a closer look at the code it appears that it may be creating a container. Maybe the title of the issue just needs to be updated?
Comment #5
vegantriathleteI do believe this will be addressed by #1535232: og forum administration