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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • CiviEvent convert user id to participant
Pages: [1]

Author Topic: CiviEvent convert user id to participant  (Read 1895 times)

TravelingPharaoh

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 3
    • Traveling journey of a developer
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 7
CiviEvent convert user id to participant
November 15, 2009, 08:37:17 pm
I didn't see an API that would get me the events in which a contact is registered.  Would it be accurate to say that I could do the following:

-- To get the events a contact is registered in
within my drupal code do the following pseudo code
- convert drupal id to civicrm contact id       
    $civiuserid = civicrm_uf_match_id_get($user->uid);

- select id, event_id from civicrm_participant where contact_id = $civicrm_contactid
do while fetch ok
    $params = array(
                    'id' => event_id
                    );
    $result = civicrm_event_get( $params );
    if ($result->is_active == 1)
           $listofevents[]=$result->id;
   





   



TravelingPharaoh

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 3
    • Traveling journey of a developer
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 7
Re: CiviEvent convert user id to participant
November 17, 2009, 07:50:25 pm
Just to close this not, to convert a contact ID to participant you have to query the civicrm_participant table


select id, contact_id ,event_id from civicrm_participant where contact_id = userid;

The id returned can be then piccked up to retrieve data related to participants.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • CiviEvent convert user id to participant

This forum was archived on 2017-11-26.