Download & Extend

Auto-create og on user registration

Project:Organic groups
Version:6.x-2.1
Component:og.module
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I'm looking for a way to automatically create an organic group when a user first registers.

Ideally, this would be based on the user's username, email address or other unique identifier, with the group added behind the scenes. All other og admin functions would remain, such as og delete, add users etc.

Is it possible that this function has already been implemented somewhere? Yes, I'm trying to avoid writing it myself.

Many thanks. OG is a GREAT piece of work!!

Comments

#1

i don't think it exists but the logic will be something like og_mandatory_group which also acts upon registration.

#2

Status:active» closed (fixed)

some other module will need to implement this.

#3

is it possible to do this now with drupal 6 and rules?

Thanks in advance.

#4

I haven't done this with rules, but it should be possible. You can make a small custom module that adds a group node for each user that registers, possibly by implementing a _user hook in your module. (http://api.drupal.org/api/function/hook_user/6)

Here's the code that you could call in an action your hook, essentially builds the basic for the group node specific to the user, and saves it.

Hope this helps, and I'm sure there is a smoother way you could do this...
-M

$gnode = array();
$gnode['type'] = 'group';  (your group type name may be different)
$gnode['status'] = '1';
$gnode['promote'] = '0';
$gnode['title'] = $form_values['groupname'];  (user's group name)
$gnode['body'] = $form_values['mission'];    (some value from your reg form if like)
$gnode['og_description'] = 'empty';
$gnode['og_register'] = 0;  (don't show in reg form)
$gnode['og_notification'] = 1;  (enable group notification)
$gnode['uid'] = $user->uid;  (set the group node uid)
$gnode['name'] = $user->name;  (set group owner name)
$new_group = node_submit($gnode);
node_save($new_group);

#5

Thanks for replying.

I'll have to wrap my head around this one ;-)

#6

Did you get this working?

I am running a couple of Drupal 5 websites and I would like to implement something like this too?

But I am not a programmer.

Regards,
Paul

#7

Status:closed (fixed)» needs review

@juicytoo #3

Yes it can be done with D6, Rules and Tokens. This in a very basic way. With tokens you can pull off some required data of the user form and use that for instance to create a OG name.

I assume when using content_profile you can have more fields to pull the desired data from. (or have a look at http://drupal.org/node/23710 to Create new profile fields)

Best,
VinceW

-=[ Your Information Matters ]=-

PS: I didn't change the version since it was initially a D4 issue in 2006. I've set the status to "needs review" because I would like to have more people looking into this solution in case I've overlooked some modules created after 2006.

#8

Thanks Vince,

I'll try and wrap my head around this.

cheers

#9

I did this with og and rules. One problem persists though, I cannot set those created groups to be private, but otherwise it's doable. This is with OG 6.x-2.0. I used the following rules on trigger "user account has been created":
1) create node (group-type)
2) add group node settings to that node
3) save node
I additionally stored the nid of that group in a user-profile as described in #609992: PHP code to change custom profile field. So consider this solved for the current version.

#10

Version:4.7.x-1.x-dev» 6.x-2.1

Hi there,

I'm having te same problem, I can't figure out how to set the created groups to private.

Did anyone find a solution?

Thanks!!

#11

Category:feature request» support request
Status:needs review» fixed

You can use the Rules module with its integration with OG to create new content upon user registration.

#12

Hi Amitaibu,

Thanks for your reply, that what I did, I used Rules to create OG groups but by default my created groups were public and I couldn't find a way to change it to privat, so I used a very nice module, called Organic groups defaults which does just what I needed!

Thanks again for your reply

#13

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.