CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Allow user to choose which membership year to sign-up for.
Pages: [1]

Author Topic: Allow user to choose which membership year to sign-up for.  (Read 1529 times)

alphageekboy

  • I’m new here
  • *
  • Posts: 11
  • Karma: 1
  • Web Developer
    • Alpha Geek Tech, LLC
Allow user to choose which membership year to sign-up for.
September 29, 2009, 08:11:48 am
Business Rules:

1. Potential members can come to the website and choose to sign-up for membership for the current year
2. Potential members can come to the website and choose to sign-up for the next calendar year
3. Memberships are fixed 1 year by calendar year
4. Roll-Over date is same as end of calendar year

Scenario:

Ideally, this would be a drop-down box on the top of the membership form.

1. User comes to a content page, selects "Sign-Up" and is presented with a choice to sign-up for "current year (2009)" or "next year (2010)".
2. User selects "next year (2010)" and the membership record created submits with a start date of Jan-1-2010 and end date of Dec-31-2010.

Question:

I'm assuming I would need a custom field for membership year to be added to the top of the form.  What I'm unfamiliar with is the correct way to write the post hook to change the membership dates.

Can someone point to the right place or the proper way to do this.  I'm assuming I would need to use "hook_civicrm_postProcess( $formName, &$form )". And check for the membership year, and then somehow modify the start/end date. 

Is this the right way to go? Has anyone done anything similar?

Tracy C. Smith
Chief Technologist & Founder

Alpha Geek  Tech, LLC
p: 831.706.2187
http://alphageektech.net
skype/aol: tracycsmith
t: alphageektech

alphageekboy

  • I’m new here
  • *
  • Posts: 11
  • Karma: 1
  • Web Developer
    • Alpha Geek Tech, LLC
Re: Allow user to choose which membership year to sign-up for.
November 02, 2009, 01:00:37 pm
Anyone have any ideas on the best way to do this?
Tracy C. Smith
Chief Technologist & Founder

Alpha Geek  Tech, LLC
p: 831.706.2187
http://alphageektech.net
skype/aol: tracycsmith
t: alphageektech

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Allow user to choose which membership year to sign-up for.
November 02, 2009, 03:26:51 pm
Not sure about the details of how / if this can be done w/ a hook. However here's the code flow:

CRM_Contribute_Form_Contribution_Confirm::postProcess() calls
CRM_Member_BAO_Membership::postProcessMembership() which then calls
CRM_Member_BAO_MembershipType::getDatesForMembershipType() in order to get the correct start and end dates for the new membership.

That last method can accept an optional start_date parameter - which is basically what you need to do, because then it returns the correct dates which are used to create the membership.

So you MIGHT be able to do the following:
- use buildForm hook to inject your additional drop-down or checkbox (for this year or next year ...)
- use postProcess hook to grab the already created membership record and your custom field value - and then use the getDates... BAO to calc the new date range and then update the record with new dates.

Question: What if I want to signup for this year AND next year ??
« Last Edit: November 02, 2009, 04:27:28 pm by Dave Greenberg »
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Allow user to choose which membership year to sign-up for.

This forum was archived on 2017-11-26.