我正在尝试以编程方式创建一个组节点,并在Drupal 7中将用户添加到该组中。正在创建组节点,但是没有将用户添加到该组中,并且没有出现任何错误。我猜我使用的og_group函数不正确,但是我不确定。我究竟做错了什么?
function MYMODULE_form_submit($form_id, $form_values) {
global $user;
$node = new stdClass();
$node->type = "group";
$node->uid = $user->uid;
$node->title = t("Group Node Title");
$node->body = t("Group Node Body");
$node->status = 1;
$node->promote = 0;
$node->comment = 1;
$node->og_description = t("OG Description");
$node->og_register = 0;
$node->og_directory = 0;
$node->og_private = 1;
$node->og_selective = 3;
$node = node_submit($node);
node_save($node);
$account = user_load(2);
og_group($node->nid, array(
"entity type" => "user",
"entity" => $account,
"membership type" => "OG_MEMBERSHIP_TYPE_DEFAULT",
));
drupal_set_message(t("Finished"));
}
嗨,麦克斯-您提出了一个很好的问题。thx很多
—
零