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) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Membership Best Practices
Pages: [1] 2

Author Topic: Membership Best Practices  (Read 2688 times)

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Membership Best Practices
January 05, 2013, 06:21:13 pm
Hi guys, I am a noobie user to CIVICRM but have decent PHP and programming skills, I am using Joomla 2.5 and CIVICRM 4.x  We run a non profit that has basically annual members.  The problem I'm having is this:

The membership ID number (CIVICRM ID) is important and we print it on their Membership cards, and we use that ID to track athletes at tournaments.  So a parent might be an athlete and 3 kids in their house are athletes too.  How do I allow them to edit all 4 memberships?  When the create an account with their email account and login to renew how can they renew the propper ID number when all 4 memberships are under the same email?

How should I go about this?

Thank you !

David

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Membership Best Practices
January 06, 2013, 02:11:42 am
Hmm there is not a standard profile you can use as far as I know, and the Drupal Webforms - CiviCRM integration does not help you on Joomla :-)
So unless a Joomla CiviCRM expert has another idea, you would probably use the standard membership profile, and create a civicrm hook (buildForm) to add the kids. I would assume you would find them because they have a certain relationship with the 'head' member? You can use the CiviCRM API to get data from the database. Then use a post or a postProcess hook (one is on the DB action, the other on the form - whatever does the job best for you) to process the additional data with the API. Details on hooks and API can be found here : http://book.civicrm.org/developer
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Re: Membership Best Practices
January 06, 2013, 09:49:10 am
Is there any way for me to set it up so that on the renewal form it would simply show all records associated with that email address and let the user cycle through them 1 at a time? That way a parent who logs in can edit their profile natively (the joomla linked one) then cycle to the next one and edit it.  I realize "all things are possible through hooks" but I'd prefer to have as little custom programing as possible to keep the project simple.  Whats the best way with the least programming?

David

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Membership Best Practices
January 06, 2013, 10:22:47 am
The simplest as far as I am concerned is using the API to retrieve and update data from/to CiviCRM. But I will leave it to experienced Joomla dudes and dudettes :-)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Re: Membership Best Practices
January 06, 2013, 04:21:53 pm
Thanks for the reply I would really love a sample, I've looked at the developer docs and they seem pretty straight forward but since this is my first CIVICRM deployment ever, I am willing to outsource this coding project if it comes to that, a php sample would be phenominal.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Membership Best Practices
January 07, 2013, 12:11:20 am
The easiest way is to look at the folder /civicrm/api/v3/examples. You will find examples of PHP usage there. There is also the API explorer (<yoursite>/civicrm/api/explorer) that will assist you in what is possible.
Example of PHP code to create an activity:
Code: [Select]
    $actParams = array(
        'version'           =>  '3',
        'source_contact_id' =>  '150',
        'target_contact_id' =>  $targetID,
        'activity_type_id'  =>  $actType,
        'status_id'         =>  '2',
        'subject'           =>  $actSubject,
        'details'           =>  $actDetails );
    $actData = civicrm_api( 'Activity', 'Create', $actParams );
    if ( $actData['is_error'] == 1 ) {
        $result['is_error'] = '1';
        $result['error_msg'] = $actData['error_message'];
    } else {
        $result['is_error'] = '0';
        $result['activity_id'] = $actData['id'];
    }
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Re: Membership Best Practices
January 09, 2013, 10:40:37 am
I had a stroke of genius I wanted to run by you:

What if i did this little bit of hacking:

So the table that tags the joomla user id to a civicrm contactID, and we have duplicate email addresses for 5 members in the same houehold or club.  So what if i made a hook with hyperlinks with all duplicates at the top of the "edit profile" with all duplicate members and when the click on the link it edits the CIVICRM - Joomla USERID relationship to reflect the member they just clicked.

For instance

Richard Richardson is JoomlaID 3 and CiviCRM ContactID 1000

When Richard logs into Joomla for the first time it tags this relationship.

Then Richard wants to register a membership for his 1 kids and 2 other non related kids at his club he is just paying for as the club coach.  All 4 of these contacts share the email address of Richard.

Sally Jones
John Jones
Bill Richardsdon


So when he clicks on edit profile (while logged into the CMS of course) of civicrm he gets some custom HTML at the top that says:

Switch to Sally Jones
Switch to John Jones
Switch to Bill Richardson


When Richard Richardson clicks one of those links the Hook kicks in and runs SQL code to change the Joomla USERID field in the CIVICRM contact table from Richard Richardson (userid 3 to civicrm_id 1000) to Sally Jones (userid 3 civicrm_id 1066) then the reload of the edit profile page fires and bingo Richard Richardson's Joomla accont is now tagged to Sally jones.

Any thoughts on this design scheme? It seems like a lot easier way to allow the functionality i need with minimum hacking required, to use the intended functionality of the CMS link to CIVICRM id editing and just changing one piece of data vs making a whole new page and extensive API calls.

David
« Last Edit: January 09, 2013, 11:24:50 am by shinzan »

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Membership Best Practices
January 09, 2013, 10:46:22 am
So how do you know they belong together in the first place? Or am I missing something?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Re: Membership Best Practices
January 09, 2013, 11:27:33 am
Primary Email address.

When a parent signs up his childeren or a coach signs up his students a lot of times they use their own email address.  They need the membership ID number (which we are using the contact ID in civicrm to replicate.)  I fiddled with the auto increment identity column to import our 10 thousand contacts and make their id numbers of civicrm match the old id numbers.

These ID numbers are required when a member signs up for a tournament or an event, so we can track them in our tournament software for ranking and other things.

So my requirement is that the owner of an email address be able to edit all other contacts and organizations that list that email as their primary contact.'

I guess the other question I have is where is the relationship of Richard UserID 3 in Joomla and 1000 contact id in civicrm saved what table?  I figured it would be in contact under like CMS ID or something like that but i don't see it anywhere.

Thanks!

David
« Last Edit: January 09, 2013, 11:43:40 am by shinzan »

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Re: Membership Best Practices
January 09, 2013, 01:44:18 pm
Actually I had another brain storm to keep me from having to delve to far into the API docs.  I can simply create an intermediary PHP page to manage the "landing page" for membership renewal or editing, all i need to know is what table holds the linking relationship of Joomla UserID and associated Civicrm Contact ID, then i can query the database for all contacts that are of the same email address of the AUTHENTICATED user -- granted i would have to disallow changing email addresses in the CMS once you create an account, display them with a link(s) of all possible members they "own" then, on the postback of the link it swaps the userid in the civicrm table and loads the appropriate page easy peasy lemon squeezy. 

Anyone know?

David

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Membership Best Practices
January 09, 2013, 03:18:09 pm
That table is civicrm_uf_match.

Not sure I would actually swap user sessions though. :-(

Some other 'features' to check into are:
- permissioned relationships and the ability for a contact w/ permissioned relationship to others to view and edit the related persons' contact info via links in the Contact Dashboard
- feature allowing memberships to be purchased by person A FOR person B. this is in 'core' in the backoffice Membership form ('Record Payment from a Different Contact') and Eileen from Fuzion in NZ has done some work to implement for self-service (I asked her to comment on your other post).

Protect your investment in CiviCRM by  becoming a Member!

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Re: Membership Best Practices
January 09, 2013, 03:26:42 pm
I did see Eileen's post on the other thread and looked at that one and it seems like it could be useful but I posted some additional questions for her there.  It seems to me however that switching the session just is the 10 lines of code solution to my entire problem and retains all my business logic and makes no core hacks or hooks even necessary for CIVICRM and in my opinion those are always good things in programming projects.   Also I need to allow editing of these "child memberships" from a central login, which that module may not do (I asked in the other thread) What are the specific reasons for not switching user sessions?

Because if I wrote a module to allow for that I'd be done tonight I think.  Is there a way to swap sessions? Or would I have to force a logout of the Joomla CMS and make them login again (validate login before editing another member...would be how i'd sell it)

I can easily have a landing page that says something like:

Your Members
Richard Richardson (MemberID 1000)
Sally Jones (MemberID 500)
Tom Jones (MemberID 1232)
Bill Richardson (MemberID 1533)


and when you click it, the table ids are swapped and joomla logs out the user simply with the code:

$app = JFactory::getApplication();
$app->logout( $user_id );

Then redirects them to my "validate your credentials to continue Editing Member Bill Richardson..." Page

My key question that would have the crux of this project done is:
1) How can I repopulate the CIVICRM Cache Progratically in PHP without logging out and logging back into the CMS?

Also to give you a concept of the impact of the same email address being used for 2 or more contacts (for better or worse) we have over 1000 contacts in our 10000+ membership that a duplicate email, some clubs registered all contacts under their name and have 32 members as their email!! So my desire to allow people to edit these things on their own, and not interfere with our long standing business logic is a high priority, and I've been researching CRMS for two years before I made the decision to switch to this one (its a clear winner) So Id love to keep my business logic and take advantage of this Ferrari at the same time.  I'm not opposed to permissioned relationships but the problem there is, its not realtime.  It requires intervention on our part to setup those relationships which already exist by a duplicate email -- and it happens 10% of the time!  I want to work smarter with CiviCRM not harder so I need realtime access to everything with as little user and administrator interaction as possible.  I need a user to pay for a membership and be able to know their ID immediately (so they can mozy on over to tournament registration and register)  We already have a Tournament Registraion website with a membership checking system API that i have hooked up to CIVICRM to prevent athletes from registering if they don't have a valid membership, so a lot is hinging on the realtime ability to get your memberhsip ID and your ability to edit multiple memberships you "own."

Thank you very much I really appretiate all the help I've been given thus far on the forums!

David
« Last Edit: January 09, 2013, 04:35:14 pm by shinzan »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Membership Best Practices
January 09, 2013, 04:46:10 pm
Allowing non-admin staff to 'masquerade' as other users opens the door to folks taking actions but not being able to know who really did it. If that's not a problem for your project, then I guess that approach could be the right one.

Would all users for related members have the same login credentials (or at least the same PW)? Else not sure how the primary member would 'login again' (but these are CMS issues so not really relevant to the Civi aspect of this).

If user is actually logging off and back on as other person, then 'repopulate CiviCRM Cache' will happen.

Else, there may be a way to change CiviCRM's user / contact handle in the session (and persist it until you want to change it back) - but I don't know how to do that.  You could peruse the code in CRM/Core/BAO/UFMatch.php, api/v3/UFMatch.php, and tests in http://svn.civicrm.org/civicrm/branches/v3.4/tests/phpunit/CiviTest/api/v3/UFMatchTest.php for clues.
Protect your investment in CiviCRM by  becoming a Member!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Membership Best Practices
January 09, 2013, 04:46:46 pm
I dont think there is a call to delete the cache for one specific user ID / contact ID. We typically delete caches system wide.

I would say, give your approach a shot and see where it runs into issues, if any. then we can think about whats happening and why

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

shinzan

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Joomla 2.5.8
  • MySQL version: 5
  • PHP version: 5
Re: Membership Best Practices
January 09, 2013, 06:13:02 pm
I will implement my project and let you know how it goes.  Its based o the user account of the CMS in joomla so in essence only one joomla user can exist per email, then all accounts they pay for using that email and tagging that email under civicrm becomes 'theirs.'The credentials being used I'm not really worried about people masqerading as other users, again the situation is parents signing up their kids or coaches signing up their athletes and needing to modify their info and renew their memberships.

Again iIts one username one password (Joomla ACL) and they can edit/renew memberships on all contacts that match their email address of the Joomla CMS username (which they have to confirm in the user account process to prove its their email account) I've already tested it an I know it works but, I would love a way to clear the cached and repopulate it without a logon logoff cycle If there is a way.  I searched the API Docs and the only thing I saw was system wide cache clear outs which of course would be a bad thing.  The user just has to logout and login to clear the cache which I disguise as a "validate credentials" style page.  It would just be a cleaner solution if it did it transparently.

David
« Last Edit: January 09, 2013, 06:45:06 pm by shinzan »

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Membership Best Practices

This forum was archived on 2017-11-26.