Search code examples
phpcustom-fieldscivicrm

How to insert custom field values in civicrm?


Hello friends I created some custom fields for contacts. How can I insert values to that custom fields. I tried to pass the custom values with params. but its not inserting. how to insert that values. Kindly help me.


Solution

  • // Define input parms for the contact and initial primary location

    $params = array(
                    'first_name'    => 'Dan',
                    'custom_{put your custom filed id here}' => "custom field value1",
                    'custom_{put your custom filed id here}' => "custom field value2"
                    );
    $contact =&civicrm_contact_create( $params );
    print_r($contact);
    

    Like this way we can insert value to custom fields