1

I am looking for a way to create a node of a specific content type at the same time as a group is created.

So basically, when a group is created a node of type my-content-type is created at the same time with og_group_ref pre-populated to associate it with the group just created...

I don't think there is a module for this, so... any pointers on to how to code this?

2
  • Ok, for anyone else trying to do this, its possible with the Drupal Rules module... Drupal never ceases to amaze me..
    – BigJ
    Commented Jan 14, 2014 at 20:38
  • 1
    Could you elaborate on how you can use Rules to answer your question? Just saying that you can make a rule doesn't really help out future users. Thanks.
    – mpdonadio
    Commented Jan 14, 2014 at 22:11

1 Answer 1

2

Here's the solution:

Obviously you need to download and install Rules, then:

  1. Add an event:

After saving new content of type Group

2 . Add conditions:

Any conditions you want here..

3.Add Actions:

a) Create a new entity

  • Parameter: Entity type: Node, Content type: ContentTypeYouWantToCreate, Title: YourTitle, Author: TheAuthor

  • Provides variables: Created entity (entity_created)

b) Save entity

Parameter: Entity: [entity-created], Force saving immediately: true

c) Add entity to group

Parameter: Entity: [entity-created], Group: [node]

your content type should now be created when you create a new group - it will also be added to the newly created group.

Done!

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.