// Get a list of honorific titles $honorifics = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); // Output the list of titles foreach($honorifics as $id => $title) { echo "$title ($id)
"; }
// Add an honorific title to a contact $contact = new CRM_Contact_DAO_Contact(); $contact->prefix_id = CRM_Core_PseudoConstant::getKey('CRM_Contact_DAO_Contact', 'prefix_id', 'Ms.'); $contact->first_name = 'Jane'; $contact->last_name = 'Doe'; $contact->save();This code creates a new contact and sets their honorific title to "Ms." using the CRM_Core_PseudoConstant class. The CRM_Core_PseudoConstant class is part of the CiviCRM package library, which is a set of classes and functions used to build web-based CRM applications.