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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • [solved] Retrieving a contact with 1.9 API on the uf_id?
Pages: [1]

Author Topic: [solved] Retrieving a contact with 1.9 API on the uf_id?  (Read 1196 times)

ClayWhipkey

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
[solved] Retrieving a contact with 1.9 API on the uf_id?
March 24, 2008, 02:58:27 pm
I'm working on a couple components that integrate CiviCRM data with the Joomla account.  Right now I have to worry about making sure the external_identifier field is always populated with the Joomla user id, but I would rather use the UF_Match stuff that you have provided so as to be more compatible with future releases.  Is there a way for me to use the API to retrieve a contact by matching the Joomla id to the uf_id in the UF_Match table?
« Last Edit: March 25, 2008, 03:59:29 pm by ClayWhipkey »

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: Retrieving a contact with 1.9 API on the uf_id?
March 24, 2008, 04:23:13 pm

check: api/UFGroup.php

Code: [Select]
/**                                                                                                                                                   
 * get the uf_id given a contact_id                                                                                                                   
 *                                                                                                                                                     
 * @param int $contactID                                                                                                                               
 *                                                                                                                                                     
 * @return int ufID                                                                                                                                   
 * @access public                                                                                                                                     
 * @static                                                                                                                                             
 */
function crm_uf_get_uf_id ( $contactID )

uf_id for joomla means the joomla user id

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

ClayWhipkey

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
Re: Retrieving a contact with 1.9 API on the uf_id?
March 24, 2008, 05:15:23 pm
Lobo, thank you.  I actually needed the crm_uf_get_match_id function but you pointed me in the right direction.  One issue I had trying to use it was I got an error like this when I attempted it as it was:

Quote
DB_DataObject Error: No database name / dsn found anywhere

That occurred when the function looked like this:
Code: [Select]
function crm_uf_get_match_id ( $ufID ) {
require_once 'CRM/Core/BAO/UFMatch.php';
    return CRM_Core_BAO_UFMatch::getContactId( $ufID );
}

Then I added the _crm_initialize() call, it worked.  So now the function looks like this and works perfectly:
Code: [Select]
function crm_uf_get_match_id ( $ufID ) {
_crm_initialize( );   
require_once 'CRM/Core/BAO/UFMatch.php';
    return CRM_Core_BAO_UFMatch::getContactId( $ufID );
}

Thanks again for the tip.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • [solved] Retrieving a contact with 1.9 API on the uf_id?

This forum was archived on 2017-11-26.