I noticed the lack of a rules event for when a role expired, so I took the liberty of integrating this myself. A patch is attached below. Please tell me if this meets the requirements of the community/project. This is my first patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lquessenberry’s picture

Tested and works well enough for our needs. This has enabled us by using a combination of modules, to easily manage paid subscriptions on our client's site by triggering an event to rebill the user via Stripe Commerce for a recurring subscription. Great work clayfreeman! As requested, please provide input as to whether or not this patch is useful to the Role Expire development community.

Note: this patch allows you to use a role expiration as a way to provide the Rules interface with an event that allows the Rules module to take action once a role expires.

phrankle’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2

This doesn't seem to work for 7.x-1.0-beta2 -- there are no role expire rules event options.

phrankle’s picture

Is there any way to use the expiring role as a condition? For example, when role A expires I'd like to create a rule replacing it with B. When role C expires, I'd like to make another rule replacing it with D.

In my first rule, I have "Add user role B" as an action. How can I specify "when role A expires" as a condition? Thanks for any help!

phrankle’s picture

Issue summary: View changes

Words; because grammar.

mr.york’s picture

Issue summary: View changes
FileSize
2.27 KB

Add account parameter in rules event.
Fixed little coding standards.

mr.york’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
mr.york’s picture

FileSize
2.33 KB

Add documentation befor implementation of hook_rules_event_info().

mariagwyn’s picture

Trying to apply patch rulesEventOnExpire-1820306-6.patch, "corrupt patch at line 56". Get it every time.

yenidem’s picture

I applied the patch, there is appeared event "When a role expires" and I also added action "send email to user".
But there is no option about notification time, I think it will inform to user when his account expired, can we set any time period before expire date? I want to inform user before 1 week ago from his account expire date.

please advice and thank you.

mr.york’s picture

FileSize
1.25 KB

Remove codeing standard fix in the patch.

pinkonomy’s picture

Patch from #9 worked for me.

jsibley’s picture

Does this need further testing? Can it be committed now?

Thanks.

redboxhosting’s picture

it is very good patch!
worked for me too. It should be committed I think.

joshmiller’s picture

Status: Needs review » Reviewed & tested by the community

It's an extremely simple patch that does the job. Tested and will be using this patch on production. No problems at all.

Josh

rcodina’s picture

Thanks for your work. I have added an "if" to prevent errors on installations where rules is not installed:

if (module_exists('rules')) {
  rules_invoke_event('role_expire_rules_event_role_expires', $account, $role_name);
}

  • rcodina committed 16921d1 on 7.x-1.x authored by mr.york
    Issue #1820306 by mr.york, clayfreeman, phrankle, mariagwyn,...
rcodina’s picture

Status: Reviewed & tested by the community » Fixed
rcodina’s picture

Assigned: clayfreeman » Unassigned

Status: Fixed » Closed (fixed)

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