I am trying to create forums as a result of a node being added. These additions happen from within a user action. However, I am struggling to find an API for forum creation. Is forum_submit the best point?

Any suggestions are greatly appreciated.

Comments

regli’s picture

I found a thread that addresses the issue:

http://drupal.org/node/64520

regli’s picture

The code presented in that other post does not establish a forum but creates a forum topic. Forums are established via Taxonomy and only topic are nodes.

Here is some code that establishes a new forum. Hope it helps somebody down the line.

	$arr_forum_term = array('name' => $ftitle,
	                          'description' => $ftitle,
				  'vid'  => VID_FORUMS,
				  'weight' => 0,
				  'parent' => TID_FORUM_PARENT,);
  	$arr_terms = taxonomy_get_term_by_name($ftitle_bull);
  	$boo_create_forum = TRUE;
  	if (empty($arr_terms)) {
	  foreach ($arr_terms as $term) {
   	    // check if the forum already exists not just the name
  	    if ($term -> name == $ftitle_bull && $term -> vid == VID_FORUMS) {
  	      $boo_create_forum = FALSE;
  	      $tid = $term -> tid;
  	      break;
	    }  
  	  }
  	}
  	if ($boo_create_forum = TRUE) {
  	  // forum doesn't exist therefore create  
  	  $result = taxonomy_save_term($arr_forum_term);
 	    // tid is updated in the save process
  	  $tid = $arr_forum_term [tid];
  }
liam mcdermott’s picture

Status: Active » Fixed

Marking as fixed. Thanks for posting the answer, it may well help someone else later!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.