Skip to main content
2 of 2
added 199 characters in body
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
//Load and init the Drupal System
require_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once 'modules/forum/forum.admin.inc';

function fourm_activities_form_alter(&$form, &$form_state, $form_id)
{
my_debug($form_id);

  if($form_id == 'testing_forum_node_form')
  {
    global $base_url;
//      my_debug($form);
    //add function to complete to at the end of array
    
    if(arg(2) && arg(2)!= 'edit')
    {
        $form['buttons']['submit']['#submit'][]='fourm_activities_form_id_submit_handler';
    }
  }
}
    function fourm_activities_form_id_submit_handler($form, &$form_state)

    {
        $name   =   $form['nid']['#post']['field_test'][0]['value'];
        
        $test_nid = $form_state['nid'];
        
        global $user;
    
        $newNode            = (object) NULL;
        $newNode->type      = 'forum';
        $newNode->title     = $name;
        $newNode->uid       = $user->uid;
        $newNode->created   = strtotime("now");
        $newNode->changed   = strtotime("now");
        $newNode->status    = 1;
        $newNode->comment   = 0;
        $newNode->promote   = 0;
        $newNode->moderate  = 0;
        $newNode->sticky    = 0;

        node_save($newNode);
        $final_nid =    $newNode->nid;
        
        $node = node_load($test_nid);
        $node->field_forum_reference[0]['nid'] = $final_nid;
        node_save($node);
        
        //$form_state['clicked_button']['#post']['field_forum_reference']['nid']['nid'] = $newNode->nid;

}
Zaid
  • 129
  • 9