Hey all,

Thank you for your work on this module, which fits the most part of my current needs on the site I am working on.

I have on question though : I spent all the day long looking how to automatically create a membership to a newly created user, through the Rules module.

Nevertheless, I clearly did not get the meaning of the "Internal ID" required by Rules, and do not understand why the Member ID must be declared.

If any one have an example to share with us, it would be very appreciated...

Best,

Alan.

CommentFileSizeAuthor
#1 Membership.png49.84 KBPilou7534

Comments

Pilou7534’s picture

StatusFileSize
new49.84 KB
Channel Islander’s picture

Hey Alan,

Too bad there was no response to your question!

In our system we have the Memberships available for sale through the Drupal commerce store. There is a Rule to activate the Membership that can be set to fire on payment, order completion, or whatever, and you can use Rules to control your store. You would need the Membership terms to be available as products in the store, but they could be priced at 0 and afaik you could use rules to automate a "purchase" upon user registration. All of that convoluted mess to get you to where you can use the one Membership Term Rule that is available.

All I can offer as I am a user not a developer of these modules.

Good luck

Rosamunda’s picture

I would like an example too! :)

Channel Islander’s picture

Hi again,

I came back to this thread with a little more knowledge. Maybe it will help.

1) In the newest version of Membership Entity -dev branch, you can configure your User Account settings to make Membership creation a part of Registration. Sounds like what you need. No Rules needed.

2) You can still use Membership Entity Commerce to charge for the new Membership as it is created during Registration.

3) With Rules, and not depending on the -dev branch, I got as far as creating a Membership for the user. This Rule assumes that you have your Membership Type configured to use numeric [mid] and [member_id], and it uses the new account [uid] for those values. It also depends on the PHP filter module, which is in Core but disabled by default.

{ "rules_add_membership_to_new_user" : {
    "LABEL" : "Add Membership to New User",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "php" ],
    "ON" : { "user_insert" : [] },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "membership_entity",
            "param_mid" : [ "account:uid" ],
            "param_member_id" : "[account:uid]",
            "param_type" : "membership",
            "param_primary_member" : [ "account" ]
          },
          "PROVIDE" : { "entity_created" : { "membership_entity_created" : "Created Membership entity" } }
        }
      },
      { "php_eval" : { "code" : "membership_entity_save($membership_entity_created);" } },
    ]
  }
}

Note that this just creates a Membership for the user and without a Term the Membership isn't much use. It may not even be the right way to create a Membership in code.

When I added Actions to create and save a Membership Term for the Membership, I got a fatal error:

Fatal error: Call to undefined method MembershipEntityTerm::setmembership() in /sites/all/modules/contrib/entity/includes/entity.property.inc on line 437

That's all I know :-)

Yuri’s picture

I used the 'create entity' > Membership rules action...but the membership is not created.
Just wondering if anyone has successfully used rules to create memberships and set its term.