I have made a hook_node_insert which when I create a group content of type A, it create a node group. I want to associate my type A with the created group with the field audience. I have changed the field group audience like that

$nodeA->group_audience = array(
    LANGUAGE_NONE => array(
        '0' => array(
            'gid' => $group->gid,

But it doesn't save the data into the database. I have tested with node_save but I have the error that primary key nid is duplicated.


1 Answer 1


Unless you're changing the $node inside a node_save() or something, your changes won't make it into the database unless you add a node_save() after the change to $node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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