Jump to content
Rudy

Memberships and development approach

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

Share this post


Link to post
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

Share this post


Link to post
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
 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndZyk
      Hello,
      this maybe a simple question, but it bothers me for a while now:
      There used to be a warning, if two or more user try to edit the same page. But ever since AdminThemeUIkit I haven't seen it any more.
      Is this a bug or are there special circumstances under which the warning will be displayed?
      If I am logged-in in the same browser with one default and one privat window, I don't see this warning. But also different browsers on different machines in the same network don't see this warning.
      I was looking for the blog post on which this feature was announced, but couldn't find it anymore.
      We had the case, that two people were writing a text for the same page, but after person A saved the page first, the text of the person B was lost. I know we could have used ProDrafts for this case, but it shouldn't happen in the first place.
      I would appreciate some feedback. 😀
      Regards, Andreas
    • By SwimToWin
      I have a website that allows users to create their personal "website" (a page with sub-pages).
      Users shall be able to:
      Log in (frontend and/or admin), Edit "their" page(s) - I am using the "Page Edit Per User"-module (https://modules.processwire.com/modules/page-edit-per-user/) to grant access to the relevant pages Create child pages - possible? Users shall not be able to see other pages in the admin interface - "Admin Restrict Page Tree" may do the trick (https://modules.processwire.com/modules/admin-restrict-page-tree/)? Frontend editing shall be possible - I am considering "Fredi" (https://modules.processwire.com/modules/fredi/) for this. The challenge is that it takes a lot of modules and configuration.
      Is there a way to set this up that doesn't require a lot of configuration for each new user?
    • By quickjeff
      Hey guys, 
      Looking for another dev to help on multiple processwire projects as well as some other PHP apps. 
      First project is a directory style site with lots of components to come, including stripe implementation  and other fun stuff.
      Need someone ASAP to help out. 
       
      Thanks.
    • By benbyf
      Hello, having trouble getting PW to save my user or field in cron hook.
      It seems to report the same field info each time unchanged. It should be counting down in seconds.
      public function init() { // set to every30Seconds in settings $this->defaultInterval = $this->cron_check; // add hooks to CRON $this->addHookAfter("LazyCron::{$this->defaultInterval}", $this, 'checkUserSubscription'); } public function ___checkUserSubscription(HookEvent $e){ // seconds since last lazycron $seconds = $e->arguments[0]; $log = wire('log'); $field = $this->exclusiveRole; // users with specific role and field $users = $this->users->find("roles=$field"); foreach ($users as $user) { // get stored time $currentTime = $user->get($this->fieldName); // if time not null if($currentTime){ // evalute stored time minus time past $resultTime = intval($currentTime) - intval($seconds); $log->message("result ".$resultTime); // save user page $user->set($this->fieldName, $resultTime); $this->users->save($user); } } }  
    • By benbyf
      HELLO! having user Role issues.
      I've got a Role:  members and a template that is set to only allow view of Members and to redirect anyone else to / but id redircts Member users still currently, and only alows people to view the page if the template is set to view on the guest role also.
      Any help would be appreciated. I'm running  ProcessWire 3.0.62



×
×
  • Create New...