$fieldParams = array( 'name' => 'my_custom_field', 'label' => 'My Custom Field', 'data_type' => 'String', ); $field = CRM_Core_BAO_CustomField::create($fieldParams);
$field = CRM_Core_BAO_CustomField::retrieveByName('my_custom_field'); $field->setLabel('Updated Custom Field'); CRM_Core_BAO_CustomField::update($field);This example retrieves an existing custom field called "my_custom_field", updates the label to "Updated Custom Field", and saves the changes using the update method. The CRM_Core_BAO_CustomField class is part of the CiviCRM Core library.