We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Expire Users with SCM Extension & Cron Job -- Does this work?

Development and Programming

Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Right, well I have a revised version of the Extension which I have written which now includes a control panel setting screen to allow you to specify the subscription period and also the member group that paid members are assigned to upon completing a transaction using the simple commerce module.

I think once I have the standalone template which will be triggered by a CRON job working as expected the next step would be to try and wrap that up into a plug-in that accompanies this extension. The only issue I can foresee at present would be that of the email body content.

Greg, if you are happy for me to share the revised extension here please do let me know and I’ll attach it to this post.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Would love to see what you have created there Nathan just as I love learning from other peoples extensions an what-not 😉

Here’s hoping Greg says yes 😊

Best wishes,

Mark

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Well I have the template script running too also now, it sends an email if your subscription is due up within the next 10 days and reverts your membership back to the default member group once the renewal date has passed.

Seems to be working a treat!

Greg… you here? 😉

       
jasonathopi's avatar
jasonathopi
35 posts
16 years ago
jasonathopi's avatar jasonathopi

This is exactly what I am needing, any chance you will go ahead and release this. Or maybe you could just email me : )

       
Greg Aker's avatar
Greg Aker
6,022 posts
16 years ago
Greg Aker's avatar Greg Aker

Hey Nathan,

Sorry for not seeing the response!

By all means, share away =)

-greg

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Ok, well Greg has very kindly stated that he is happy for me to share my modified version of his extension and my CRON job template here.

The EE page template is set up as a standard template in EE with PHP enabled and is then called every night by a CRON job running on the server.

I have tested this pretty thoroughly here and it seems to work fine though I’ve yet to see it running ‘in anger’ as the site it’s used on does not launch until the new year.

EDIT: I should add that the main differences between Gregs original extension and this are that I have added a settings screen for the Extension to allow you to specify the subscription period after which users should expire (in seconds, for ultimate flexibility!) and also the member group id that paid members will belong to. Both of these values were hard coded in the original extension.

I have also modified ever so slightly the way the extension sets the renewal date if an already paid up member re-subscribes before their account expires. Previously the renewal date became the current date, I have changed the behavior so that the renewal date defaults to the expiry date, so that a member can pay up for an extended subscription way before expiry without missing out. This could be added to the settings screen as an option I guess.

The next ‘neat thing’ to do would be to wrap the PHP code for the template into a plug-in so that the whole process is a little easier to implement. Any suggestions appreciated! 😊

UPDATE: During testing today I ran into a number of issues with the Extension and so I’ve updated it quite considerably to now include the following amendments:

1: When you delete a member manually via the EE CP the extension is called in order to tidy up the ‘exp_paid_members’ table at the same time keeping things nice and tidy.

2: When the extension is called by the simple commerce module it now checks that the simple commerce item which the user has purchased is set to modify the member group upon purchase, if it is, the extension does it’s stuff, if not it does nothing. This means that you can have a site with additional items that should not modify the member group and users purchasing those items will not be added to the ‘exp_paid_members’ table as previously.

3: I’m also now keeping a record of the simple commerce item ID in the ‘exp_paid_members’ table such that the EE template which runs as a CRON job could be modified to effect only paid memberships for certain products (a bit of forward thinking).

That’s it for now! I’ve updated the attached files.

       
jasonathopi's avatar
jasonathopi
35 posts
16 years ago
jasonathopi's avatar jasonathopi

Hey Nathan, First let me say thanks for releasing this for public use.

I cant even call myself a noob when it comes to PHP I’m worse than that. But I know my way around EE pretty good.

I have downloaded your .zip and installed everything as well as enabled the extension, created the PHP template, and adjusted the settings. My question is…

What do I do now? Is that all? How do I link all of this together with my site?

I am hoping this is a short explanation so I won’t take up to much of your time.

Thanks

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Hi there. Make sure you have enabled the extension first of all, and set the values in the settings screen. The extension will then take care of adding members to a new table in the DB when they join the ‘paid member group’ that you specify and it’s this table that the EE template queries to check expiry dates when you set it up to be called by the CRON job. The EE template also does the job of then expiring users and reverting them back to the standard members group.

That’s another setting that could be added I guess… which member group users default to after expiry. Hope that all helps! 😊

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Well, I just ran my first ‘in anger’ test where I completed a payment for membership via PayPal and was returned to the site, the payment was recorded in the SCM as expected and I was bumped up to the new member group but the np_paid_members extension did nothing! I’m wondering if any of the admins can advise at what stage in the process the SCM amends the member group, before or after the ‘simple_commerce_perform_actions_end’ hook is called???

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

During testing today I ran into a number of issues with the Extension and so I’ve updated it quite considerably to now include the following amendments:

1: When you delete a member manually via the EE CP the extension is called in order to tidy up the ‘exp_paid_members’ table at the same time keeping things nice and tidy.

2: When the extension is called by the simple commerce module it now checks that the simple commerce item which the user has purchased is set to modify the member group upon purchase, if it is, the extension does it’s stuff, if not it does nothing. This means that you can have a site with additional items that should not modify the member group and users purchasing those items will not be added to the ‘exp_paid_members’ table as previously.

3: I’m also now keeping a record of the simple commerce item ID in the ‘exp_paid_members’ table such that the EE template which runs as a CRON job could be modified to effect only paid memberships for certain products (a bit of forward thinking).

That’s it for now! I’ve updated my original post also.

       
brendanh's avatar
brendanh
32 posts
16 years ago
brendanh's avatar brendanh

Just wanted to thank Nathan for this extension. It worked perfectly, almost instantly!

Thanks!

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Glad to hear it Brendanh. I’ve actually got a new version that I need to post here which will handle manual upgrades and downgrades of members via the CP but it’s dependent upon a hook in the core files which I have had to add myself so I may hold off on posting that here until the hook is a part of the official EE distribution.

       
Mark Terpstra's avatar
Mark Terpstra
205 posts
16 years ago
Mark Terpstra's avatar Mark Terpstra

This sounds perfect, Nathan…. but I think I’m missing something.

I installed & enabled the extension - then clicked on “Settings” and I only see one setting field - the Subscription Period. Isn’t there supposed to be other settings to set? Are there some steps I need to take before enabling this?

Thanks

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Did you also set up a EE template to be called via a CRON job (or other means) and include the provided code sample? The extension only does half the job… it adds a member to a exp_paid_members table when the user returns from PayPal having paid for a product. The product ‘must’ also be set to assign the user to a new member group upon purchase, the extension checks to see if that is the case and intervenes at that point to add the user details to the custom table.

The EE template that is called via CRON then does the job of reviewing the logged user details in exp_paid_members on a daily (or whatever) period and then rolls those users back to the default members group (id 5) if the membership has expired. This is where the setting for period comes in. It’s used by the extension to set the ‘expiry’ date for the member in exp_paid_members and this is then compared to the current date by the EE template.

In time I’m hoping to make the extension more complete so that the EE template need only ‘call’ it and it will then handle the task of querying the exp_paid_members table, negating the need for so much code in the EE template.

I’m also planning to add options to allow you to specify the ‘fall back’ member group for expired users and find a smarter way to have the admin enter details for the emails that are sent when a user is nearing expiry or has expired.

At the moment the documentation is a little light (non existent!) but I’ll see what I can do about that. Obviously feel free to chip in and makes suggestions for improvements and I’ll see if I can incorporate them. 😊

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Almost forgot, I also wrote a little plug-in to use with the extension to return the expiry date for any member ‘username’ from the exp_paid_members table. So you can use this in your EE templates to display to a user their expiry date. This is most useful if you are using the Solspace User module to create your member profile pages.

I’ll attach a copy of this to the original post as well as here.

       
1 2 3 4 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.