Answers.Body: <p>You should always use the API and only if there is no other route grab the SQL table. You do not need to connect to any CiviCRM database when using the API.
  You can find more information on the API in the Developer Guide: <a href="https://docs.civicrm.org/dev/en/latest/api/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/api/</a></p>
  
  <p>Do I understand correctly that you want to send data to your other application when a membership is created in CiviCRM? If this is the case you should develop a CiviCRM extension using the post hook. You can find more information on developing an extension in the Developer Guide: <a href="https://docs.civicrm.org/dev/en/latest/extensions/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/extensions/</a> and also on the post hook: <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/</a>.</p>
  
  <p>The post hook will allow you to retrieve all the membership data from the $objectRef object when you catch an $objectName Membership and $op create (or probably edit as well when a membership changes?).</p>
  
  <p>Alternatively you can pull data from CiviCRM using the API if synchronizing every hour/day is enough?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-03T16:45:09.407Z
Answers.LastActivityDate: 2020-03-03T16:45:09.407Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>Maybe this is helpful to connect CiviCRM users/Joomla users ? I have used it in the past. 
  <a href="https://www.joomlapolis.com/blog/nick/18849-joomla-to-civicrm-user-sync-2-1-1-released" rel="nofollow noreferrer">https://www.joomlapolis.com/blog/nick/18849-joomla-to-civicrm-user-sync-2-1-1-released</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-20T17:57:37.710Z
Answers.LastActivityDate: 2020-05-20T17:57:37.710Z
Answers.UserDisplayName: Mary N
Body: <p>I'm new to Joomla, CiviCRM and PHP, but looking to help with a small project.  I'm looking to grab the members data from CiviCRM and transfer (or update if users already exist) into a different database of an application (that is stand alone code/not in joomla) for users that are members of both. After the migration of existing users is done, then going forward this process would be done when a new user registers as a member in the CiviCRM. A couple questions:</p>
  
  <ol>
  <li>Should I write PHP/SQL to go directly against the CiviCRM Contact table or utilize the CiviCRM API?</li>
  <li>Where do I write the actual code to connect to the CiviCRM database, write SQL to grab data, etc.? Is it a Joomla extension, a function when the user clicks Submit in the member registration form in CiviCRM? I'm still trying to figure out the Joomla platform and how coding works in it.</li>
  <li>Anything else I should consider?</li>
  </ol>
  
  <p>Thanks so much!</p>
  
Tags: <contacts><api><extension><joomla><database>
Title: CiviCRM Membership data to external Database
ThreadText: # CiviCRM Membership data to external Database
  
  (Asked by: username_0 on 2020-03-02)
  
  I'm new to Joomla, CiviCRM and PHP, but looking to help with a small project. I'm looking to grab the members data from CiviCRM and transfer (or update if users already exist) into a different database of an application (that is stand alone code/not in joomla) for users that are members of both. After the migration of existing users is done, then going forward this process would be done when a new user registers as a member in the CiviCRM. A couple questions:
  
  1. Should I write PHP/SQL to go directly against the CiviCRM Contact table or utilize the CiviCRM API?
  2. Where do I write the actual code to connect to the CiviCRM database, write SQL to grab data, etc.? Is it a Joomla extension, a function when the user clicks Submit in the member registration form in CiviCRM? I'm still trying to figure out the Joomla platform and how coding works in it.
  3. Anything else I should consider?
  
  Thanks so much!
  
  **Tags:** contacts, api, extension, joomla, database
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-03-03. Score: 3
  
  You should always use the API and only if there is no other route grab the SQL table. You do not need to connect to any CiviCRM database when using the API.
  You can find more information on the API in the Developer Guide: <https://docs.civicrm.org/dev/en/latest/api/>
  
  Do I understand correctly that you want to send data to your other application when a membership is created in CiviCRM? If this is the case you should develop a CiviCRM extension using the post hook. You can find more information on developing an extension in the Developer Guide: <https://docs.civicrm.org/dev/en/latest/extensions/> and also on the post hook: <https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/>.
  
  The post hook will allow you to retrieve all the membership data from the $objectRef object when you catch an $objectName Membership and $op create (or probably edit as well when a membership changes?).
  
  Alternatively you can pull data from CiviCRM using the API if synchronizing every hour/day is enough?
  
  
  ---
  
  ### Answer by username_2 on 2020-05-20. Score: 0
  
  Maybe this is helpful to connect CiviCRM users/Joomla users ? I have used it in the past.
  <https://www.joomlapolis.com/blog/nick/18849-joomla-to-civicrm-user-sync-2-1-1-released>
  
  
  ---
  
  