NOTE: This issue is a duplicate of #827594: Possible to send email to site admin when user roles expire?

ALSO: There's a strong 7.x patch here: #1820306: Integration of Rules Event on Role Expiration

Original Post:
I think it would be useful to set up a email template that would automatically be sent out to users whose roles have expired, to notify them of the end of their role. For those of us who are using role expire for trial periods or memberships, we could also include information about how to subscribe/renew.

CommentFileSizeAuthor
#15 role_expire-551722.patch5.99 KBguybedford
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stewsnooze’s picture

That is the second time I've heard that request. I think it is a great idea. I'd add to it that the number of emails be configurable.

For instance

n days before expiry send standard mail about renewal

n days after offer 10% off

n +5 days after offer 15% off

e.t.c.

amitaibu’s picture

With the rules scheduale module, you can already achiveve this:

for example:

On Event "User registration"
Do Action "Add role expiry", and scheduale and email.

@stewsnooze
As you can see I prefer providing a solid API and let users define in Rules thier logic.

blueblade’s picture

Hi Amitaibu,
Do you mean Rules module? I did a search but didnt find any Rules Scheduler or Rules Scheduale module...also, I dont see "User Registratin" in the Rules module installed on my site..Sorry for being stupid. Please help by adding a link to the module you mentioned above. Thank you.

BB

spacereactor’s picture

I also interest to notify user n days before expire and n days for last reminder.

stewsnooze’s picture

#3 and #4 Rules module can schedule these sorts of things. Have you looked at rules. If you look and can't see how to do it I could possible add something for it.

stewsnooze’s picture

Status: Active » Postponed (maintainer needs more info)
spacereactor’s picture

i not sure how to use rule, i can create on event user create account to set their expire date, but don't know to set schedule like 7 days to send Notification from expire date. If possible can someone create one example and I can to import it and backtrack how is it done.

guybedford’s picture

Yeah I really need this as well - I'm on the verge of needing to code it up myself.

With the Ubercart role expiry system, there are two conditional actions:

* one to send an email a specified duration before expiration (eg 1 month before).
* another to send an email when the role is revoked.

Both emails are customisable.

Rules integration would allow the exact same functionality as this. What is needed are two triggers - one for 'role due for renewal' and another for 'role expired'. The renewal warning time would be a config option of the role_expiry module itself which would apply to the trigger.

Then we could set up the system action to send an email on that trigger to the 'acting user', as determined by the trigger.

It should be relatively straightforward to integrate. These things always come down to time though! I might give it a crack over the next couple of weeks if no one else does... but can't guarantee anything.

guybedford’s picture

Status: Postponed (maintainer needs more info) » Needs review

I would argue that this is a crucial requirement for the system.

We use this for magazine subscriptions - some bought through the site, and others purchased manually. For the site purchases, ubercart role expiry works fine, but for non-site purchases, we need this module as well. Notifications are a must.

abaddon’s picture

you didnt read carefully comment #2, you can send an email a month before it expires, by scheduling a rule to execute when the role is added, if its added for a year, schedule one after 11 months and another after 12

guybedford’s picture

I have each user expiring at different times, so would need to add something to that functionality. Will see how the trade off goes between that and adding a module patch.

guybedford’s picture

(by different times, I mean after different periods of time)

stewsnooze’s picture

@guybedford Have you tried to use rules yet to set up this mail out to your users that are due to expire? How did it go?

spacereactor’s picture

I got a question maybe that i don't fully understand how rule work. Rule add a schedule date to send out Notification reminder only during the creating of new user, does rule schedule follow user expire role date or user create date. If it keep track to user create date, i will have problem when user extend their role before the schedule date and rule schedule still send out reminder notification email to confuse them and what will happen to the next cycle of expiration date?

guybedford’s picture

Status: Needs review » Patch (to be ported)
FileSize
5.99 KB

I finally decided to go ahead with adding rules integration to the module. The functionality is completed as I described in my initial message (#8).

This creates two rules events for role expiry - one 'pending' expiry event which can be set to activate a given time before the role is due to expire, and another 'on expiry' event.

Using rules, an email can easily be sent before and on expiry, or any other action can be performed.

spacereactor’s picture

I add #15 patch, under Site configuration-> Role Expire -> Set expiry warning time period (select the date)
Next step i do is create two new rules, under Rules -> Triggered rule

The first one for Role expiry pending
On event Role expiry pending
Do
Send a mail to a user (customize the email form)

The second one is User role has expired
ON event User role has expired
Do
Send a mail to a user (customize the email form)

Is this the correct setting? And is there another way to add two expiry pend instead of one? I prefer to have first reminder 30 days and final reminder 3 days before it expired. Anyway i happy to see that is possible to create notification base on user expire date.

guybedford’s picture

Glad to see you found it of use!

That's the correct setup. And yes, it doesn't currently do multiple expiry pending notifications.

Fidelix’s picture

Isnt it possible to setup multiple rules so this is achievable?

OliverColeman’s picture

For anyone who stumbles across this thread, it looks like there's a more complete solution over at #827594: Possible to send email to site admin when user roles expire?.

john.campbell-higgens’s picture

Is this now in the released or dev code? or do I still need to apply the patch.

abaddon’s picture

Status: Patch (to be ported) » Needs review

the patch isnt applied, you can apply it and report back here

(fixing the issue status, i think this needs review, port what patch?)

j_smits’s picture

When is this feature expected to be implemented in a beta version?
Thanx for this nice module,
Jonathan

Ela’s picture

subscribing

nicholasThompson’s picture

Version: 6.x-1.3 » 6.x-1.x-dev

I just tried this patch out on our dev server (with Rules and Rules Scheduler). Eventually, after getting my head around how it works, it seems to work really well!

Please commit! :-)

Ela’s picture

This patch works for me as well. Thank you!

Ela’s picture

Status: Needs review » Reviewed & tested by the community

changing status

stewsnooze’s picture

re patch in #15
Don't think this fits with the Drupal coding standards. You need brackets

+  if($rules)
+    $notified = variable_get('role_expire_pending_notified', array());

should be

+  if($rules) {
+    $notified = variable_get('role_expire_pending_notified', array());
+  }

Should have a space between the ){

+      //trigger rule event for role expiry
+      if($rules){

The comments need work. For instance

//remove item from notified list

Should be more like

// Remove item from notified list.

Also I haven't had a detailed look at what you use the 'role_expire_pending_notified' variable for but it seems it could grow out of control for a simple variable. Can you explain why you are using a variable there rather than altering the schema for instance?

stewsnooze’s picture

Status: Reviewed & tested by the community » Needs work
carl.ben’s picture

Is there a reason this similar and RTBC patch can't be committed?

stewsnooze’s picture

See comment #27. The patch breaks some of the Drupal coding standards and whilst the module isn't perfect already I think we should at least try to make it no worse. I'd be very happy to accept a patch that meets the coding standards

carl.ben’s picture

Why not commit the patch at http://drupal.org/node/827594?

Doesn't look like it has any problems.

Ela’s picture

The patch at http://drupal.org/node/827594 seems a lot more complicated than the patch here. Plus there are more problems that the maintainer listed here: http://drupal.org/node/827594#comment-3123800
It would be nice if the patch in #15 in this post be fixed and applied. :)

guybedford’s picture

Is there still interest in this? I'd be happy to add the schema and code changes if its going to be used.

leevester’s picture

Definite interest. My site has to be able to send emails to all members who have elevated role access and let them know that their support is about to be cut in half.

anrikun’s picture

#32:

The patch at http://drupal.org/node/827594 seems a lot more complicated than the patch here.

Just because a patch looks more complicated does not necessarily means that it is worse.

Plus there are more problems that the maintainer listed here: http://drupal.org/node/827594#comment-3123800

These are not problems but only questions.

guybedford’s picture

Status: Needs work » Closed (duplicate)

Thanks anrikun, after reviewing your code it does seem a lot more comprehensive and offers more features.

Certainly, the questions mentioned in http://drupal.org/node/827594#comment-3123800 all seem to be minor points and have been addressed.

So I really think your code should be committed, and this is a duplicate issue to http://drupal.org/node/827594

So the question is, why hasn't it been committed? If it's not going to be included in role_expire, it should be uploaded as a role_expire_notifications module.

I'd really appreciate official support of this, as we're using this pretty centrally in our site.

anrikun’s picture

Hi guybedford,
Now that this issue is closed, you should post your remarks at #827594: Possible to send email to site admin when user roles expire? too.
We definitely need to know the maintainer's decision.

guybedford’s picture

Sure, I will test the patch again and include any feedback when I do this.

Ela’s picture

Status: Closed (duplicate) » Active

Ok.. so the other issue was never resolved, even though this one was closed as duplicated.
Any chance of getting this patch in then?

joshmiller’s picture

Issue summary: View changes
joshmiller’s picture

Status: Active » Closed (duplicate)

Keeping the status of duplicate since the maintainer ignored the above #39 comment for 3 years ;P