Jump to content

Memberships and development approach


Rudy
 Share

Recommended Posts

Hi all,

I am currently building a custom membership functionality for a client. Here are the procedure:

User fills in a membership registration form. Based on the form data, it is supposed to do the following

  • create user, add roles (guest, subscriber OR free-trial)
  • if free-trial, remove/disable user after X number of days
  • if free-trial, add user to mailchimp list in the free-trial segment
  • if subscriber, add user to mailchimp list in the subscriber segment
  • if subscriber, create a new invoice via Freshbooks API and get Freshbooks to charge to user's credit card via Stripe

My questions:

  • What is the best approach on this? all in one module? or separate tasks into its own module?
  • Are there any existing module(s) that already do these things?

Thanks

Rudy

Link to comment
Share on other sites

I would say depends on your skills and preference.

You could code all the logic right into your template files
that's how I started, and still start some things until I figure the task get's more complicated and needs to be in a function or own class/module
stuffing all in template files feels faster in the beginning but can be a little harder to maintain depending on the complexity

Another thought, if you plan to trigger certain tasks from one point or can easily direct to one location (like setting all form action to one page) just put everything in templates
otherwise, or if there is enough evidence that you might add calls from other places, then maybe better split tasks in classes

I wouldn't put to many things in one module, for me it always got messy, so if you choose the modular way put mailchimp and freshbooks each in one module and maybe the user stuff in a separate and maybe split even user tasks in different modules if it makes sense you could even create a new page type e.g. "member" https://processwire.com/docs/tutorials/using-custom-page-types-in-processwire/ 

I don't think there are existing modules, that's because the tasks are fairly basic (create user, add role, remove user etc) and mailchimp/freshbooks depend on their own api's..

If you got more questions on this let us know

  • Like 2
Link to comment
Share on other sites

Actual i've to build a prototype with usermanagment and useractivity and for rapid prototyping the template way is not that bad...at least for me.

I use template files for routing to the different actions so all template files stay as clean as possible.

example:

---app_root (page for the app available under www.my-site.com/app/...
-----login_page (~50 lines code)
-----logout_page (~ 10 lines code)
-----register_page (~400 lines - two way auth...)

....

The separated code of the template could easy splitt in modules/classes later.

I using https://bitbucket.org/pwFoo/formhelper/

Regards mr-fan
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...