Add Location CCK field and instance programmatically to content type in Drupal 7 How does one add a Location CCK field and instance programmatically to a content type in a Drupal 7 module install? I am mainly concerned with what params need to be given to the field_create_field and field_create_instance functions, assuming it is created in the same way as core fields? I've put some examples of the params I give to these functions in creating core fields (in case this helps):

An example of the params given to field_create_field:

'field_property_price' =&gt; [
    'field_name' =&gt; 'field_property_price',
    'label' =&gt; $t('Price'),
    'cardinality' =&gt; 1,
    'type' =&gt; 'text',
    'module' =&gt; 'text',
    'length' =&gt; '20'
];


An example of the params given to field_create_instance:

'field_property_price' =&gt; [
    'field_name' =&gt; 'field_property_price',
    'label' =&gt; $t('Price'),
    'cardinality' =&gt; 1,
    'required' =&gt; true,
    'widget' =&gt; [
        'weight' =&gt; '0',
        'type' =&gt; 'text_textfield',
        'module' =&gt; 'text',
        'active' =&gt; 1,
        'settings' =&gt; [
            'size' =&gt; '20',
        ],
    ],
],


Thanks for reading.
Never mind I figured it out. The following params work (note that the entity type and bundle params are also needed, but for my own usage I add these later).

For field_create_field:

'field_property_location' =&gt; [
    'field_name' =&gt; 'field_property_location',
    'label' =&gt; $t('Location'),
    'type' =&gt; 'location',
    'module' =&gt; 'location_cck',
    'settings' =&gt; [
        'location_settings' =&gt; [
            'form' =&gt; [
                'fields' =&gt; [
                    'name' =&gt; [
                        'collect' =&gt; 1,
                        'default' =&gt; '',
                        'weight' =&gt; 1,
                    ],
                    'street' =&gt; [
                        'collect' =&gt; 1,
                        'default' =&gt; '',
                        'weight' =&gt; 2,
                    ],
                    'additional' =&gt; [
                        'collect' =&gt; 1,
                        'default' =&gt; '',
                        'weight' =&gt; 3,
                    ],
                    'city' =&gt; [
                        'collect' =&gt; 1,
                        'default' =&gt; '',
                        'weight' =&gt; 4,
                    ],
                    'province' =&gt; [
                        'collect' =&gt; 1,
                        'widget' =&gt; 'autocomplete',
                        'default' =&gt; '',
                        'weight' =&gt; 5,
                    ],
                    'postal_code' =&gt; [
                        'collect' =&gt; 1,
                        'default' =&gt; '',
                        'weight' =&gt; 6,
                    ],
                    'country' =&gt; [
                        'collect' =&gt; 1,
                        'default' =&gt; 'gb',
                        'weight' =&gt; 7,
                    ],
                    'locpick' =&gt; [
                        'collect' =&gt; 0,
                        'weight' =&gt; 20,
                    ],
                ]
            ],
        ]
    ],
],


For field_create_instance:

'field_property_location' =&gt; [
    'field_name' =&gt; 'field_property_location',
    'label' =&gt; $t('Location'),
    'required' =&gt; true,
    'widget' =&gt; [
        'weight' =&gt; '0',
        'type' =&gt; 'location',
        'module' =&gt; 'location_cck',
        'active' =&gt; 1,
    ],
     display' =&gt; [
        'default' =&gt; [
            'label' =&gt; 'above',
            'type' =&gt; 'location_default',
            'weight' =&gt; 0,
        ],
    ],
],


There are more params you can fiddle with but these are the ones that suited my needs. To figure the params (and to figure out params for other fields like this in future), first add the fields manually to the content type with the desired settings in the Drupal backend. Then in the command line go to the projects root directory and used drush eval "print_r(field_info_fields())" to see all the fields added and drush eval "print_r(field_info_instances())" to see all the field instances added.

Mirror the data and structure from the print out to use in the field_create_field and field_create_instance functions as I've done above.