I am trying to programmatically update the parent group of a bunch of nodes. But I am not having much luck. Below is what I have tried. What am I doing wrong here?

foreach ($groups AS $group)
  $node = node_load($group->nid);
  $node->og_parent = 23; //I also tried "$node->og_parent = array('nid' => 23);"

One thing to note is that all of these groups already have a parent group set. Also this is on Drupal 6.



Ok, I figured this out. Here is what I had to do.

I had to address this slightly differently. I just had to change $node->og_parent = 23; to $node->og_parent->nid = 23;.

I just had to address the specific node id and that fixed it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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