courtly
courtly
courtly
courtly

Upcoming Events

San Francisco CiviCRM Meetup - February 8th, 2012
February 8th, 2012
Come meet others from the Bay Area who are interested in, using or developing (more...)

UK usergroup - London meetup
February 8th, 2012
Come and meet others from the UK that are using CiviCRM or are interested in (more...)

Chicago CiviCRM Meetup
February 17th, 2012
Please join other CiviCRM users, administrators, and developers in the Chicago (more...)

London user and administrator training
February 23rd, 2012
A comprehensive two day hands on training course covering the configuration, (more...)

CiviCRM London sprint Feb 2012
February 27th, 2012
Following the CiviCRM training here in London, we will have a CiviCRM code (more...)

Philadelphia - CiviCRM Meetup for Q1 2012
March 13th, 2012

UK South West - CiviCRM Meetup
March 20th, 2012
Come meet others from the Area who are interested in, using or developing for (more...)

[Bristol, UK] user and administrator training
March 21st, 2012
A comprehensive hands on training course covering the configuration, (more...)

San Francisco user and administrator training
March 29th, 2012
A comprehensive two day hands on training course covering the configuration, (more...)

CiviCRM Usability, Test and Code Sprint - San Francisco (March 2012)
March 29th, 2012
This usability, code and test sprint is targeted at CiviCRM users and (more...)

CiviCon 2012 San Francisco Bay Area - April 2nd 2012
April 2nd, 2012
CiviCon is THE annual event bringing together the people who use, develop, (more...)

CiviCRM Documentation, Test and Code Sprint - after CiviCon San Francisco (April 2012)
April 4th, 2012
This sprint is targeted at CiviCRM users and developers who want to work on (more...)

CiviCRM Components

Tools for engaging your supporters...

CiviContribute


CiviEvent


CiviMail


CiviMember


CiviReport


Support desk blog: Using CiviCRM hooks and API to accomplish certain tasks ...

Not Just a Contact Database

These optional components give you more power to connect and engage your supporters.

  • civiCASE

  • Case management for clients and constituents.

  • civiEVENT

  • Online event registration and participant tracking.

  • civiMEMBER

  • Online signup and membership management.

  • civiMAIL

  • Personalized email blasts and newsletters.

  • civiREPORT

  • Report generation and template management.

June 14, 2009 - 07:15 — lobo

Over the past few releases we've been drinking a fair amount of the hook kool-aid. This has proven to be super effective and gets around the problem of hacking the core files, but still allow a developer to extend the functionality of the system in minor/major ways. We've used hooks also to implement event discounts and contribution/event tracking.

This week on IRC we had a few more questions which were effectively solved using hooks.

How do you delete a contact when a drupal user is deleted

Tom (http://www.kirkdesigns.co.uk/) wanted to delete the civicrm contact if the drupal user was deleted. The solution was to implement hook_user that gets called before civicrm's hook_user (you can do this by ensuring that your module has a lower weight than civicrm.module). Use the api call civicrm_uf_id_get to get the contact id for a given drupal user id. This is followed by an api call to civicrm_contact_delete to delete the contact.

How do you register a user in a third party system

Tom also wanted to create an account in a third party system via SOAP and store the value in a custom field. The solution was to implement hook_user that gets called AFTER civicrm's hook_user. The code in that hook is:

      $dsn = call_third_party_function();
      
      civicrm_initialize( );
      require_once 'CRM/Core/BAO/UFMatch.php';
      require_once 'CRM/Core/BAO/CustomValueTable.php';
      
      $contactID = CRM_Core_BAO_UFMatch::getContactId( $account->uid );
      $params = array( 'entityID' => $contactID, 'custom_14' =>  $dsn);
      CRM_Core_BAO_CustomValueTable::setValues($params);

How do I modify the search results to show columns of my choosing

Chris Ivens (http://joltbox.co.uk) wanted to modify the search results to show columns different from the default (name/address/phone/email). There is a little used feature in CiviCRM that allows you to display search results via a profile. In advanced search you can choose the profile from the select box (upper right corner). You can also send the profile via URL:

http://drupal.demo.civicrm.org/civicrm/contact/search?reset=1&force=1&id=1

The profile fields displayed have to have "public visibility" and be "in result set". Eileen pointed out in the forums that, the profile is used for contacts of all types (org/ind/hh), whereas a mixed profile cannot be created. Would be cool to make this a configurable variable in the database, so folks can change their default search results column. Ping us on IRC if you are interested in working on this

( categories: )

Comments

or...

For #2 I often instead use hook_civicrm_post and then search to see if a uid exists for the contact. That way you don't have to worry about module weights.

How do you delete a contact when a drupal user is deleted

It's great to see that there is a solution for this. Can you put the details in easy to follow steps?