Skip to content

Instantly share code, notes, and snippets.

@wpcrmsystem
Created December 19, 2017 22:30
Show Gist options
  • Save wpcrmsystem/509074f7979fb5fb20830ffcd039de3e to your computer and use it in GitHub Desktop.
Save wpcrmsystem/509074f7979fb5fb20830ffcd039de3e to your computer and use it in GitHub Desktop.
Programmatically Create WP-CRM System Contact
<?php
// This function should receive information from a third party data source such as a contact form, another plugin, or API.
function wpcrmsystem_add_record(){
$fields = array(
'prefix' => 'mr',
'first_name' => 'Nosecone',
'last_name' => 'Gasket',
'org' => 'Autobot',
'role' => 'Leader',
'url' => 'http://autobot.com',
'email' => 'ng@autobot.com',
'phone' => '555-555-5555',
'mobile' => '555-555-5556',
'fax' => '555-555-5557',
'address_1' => '123 Main St',
'address_2' => '#100',
'city' => 'Anytown',
'state' => 'AZ',
'postal' => '85858',
'country' => 'USA',
'additional' => 'This is some extra content.',
);
$custom_fields = array(
'Contact import' => 'Some information',
'Birthday' => '12/15/1980'
);
$categories = 'Employee, Partner';
$status = 'publish';
$author = '1';
$update = false;
$create = new WPCRM_System_Create;
$create->contacts( $fields, $custom_fields, $categories, $status, $author, $update );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment