I have different registration pages for different user roles in drupal, for some users i would like them to be able to create an OG group when there accounts is created.

I have a field in the registration form for group name which i would like to be used in creating the new group.

Im sure this is something you can do with rules but i cant seem to find any good tutorials on seeting it up any help appreciated

2 Answers 2


Use this module http://drupal.org/project/uc_node_checkout

You can assign a node/content type to a product in uber cart, so once a visitor has selected a product in the cart they can create an og group node.

for my needs I then just used rules to make the group unpublished until the visitor had a fully paid for the role in the ubercrt


Hope this will help you,

In Drupal 7, after user registration form submit you can create the group.

For this example I'm using hook_form_FORM_ID_alter

  • After the configuration of Organic groups and creating group content type(machine name is groups) using admin/structure/types/add

    enter image description here

 * Implement hook_form_user_register_form_alter().
function test_form_user_register_form_alter(&$form, &$form_state) {
  $form['#submit'][] = 'create_group_on_user_registration';
 * Custom submit function for user registration form
function create_group_on_user_registration($form, &$form_state) {
  $usr_obj = $form_state['user']; //get registered user object
  if (is_object($usr_obj) && isset($usr_obj->uid) && (your_conditions)) {// dont forget to add your conditions
    $bodytext = "group body";
    $author_id = 1;//you can change author id, i'm making admin as author
    $node = new stdClass(); // Create a new node object
    $node->type = "groups"; // Group content type
    node_object_prepare($node); // Set some default values
    $node->title = "group title2";
    $node->language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled
    //for author id I have given admin, you can give any other user id, 
    //but  that user should have permission to create group cotent type
    $node->uid = $author_id; // UID of the author of the node; or use $node->name
    $node->body[$node->language][0]['value'] = $bodytext;
    $node->body[$node->language][0]['summary'] = text_summary($bodytext);
    $node->body[$node->language][0]['format'] = 'filtered_html';
    if ($node = node_submit($node)) { // Prepare node for saving
      node_save($node);//$node->nid will have node id

  • Go through all comments
  • Make changes as per your requirements

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.