@ nicolasalejalonso
Thanks for your interest in Connections. What you want to to do is possible but it will be difficult because admittedly adding entries programmatically is kind of a pita which is something I really have to fix. The logic in adding an entry is really all based around receiving the data from the add entry form.
You actually want to use the cnEntry_Action::add()
method. You find it in the class.entry-actions.php
file which is in the same folder as the class.entry-data.php
file.
One of the first things you’ll need to do in you action callback is “bootstrap” it with the required files, actions and filters so you can add an entry. Expanding on your code:
add_action('user_register','clone_cbentry');
function clone_cbentry($user_id) {
// The class for handling admin notices.
require_once CN_PATH . 'includes/admin/class.message.php';
// The class for processing admin actions.
require_once CN_PATH . 'includes/admin/class.actions.php';
// Process entry categories.
add_action( 'cn_process_taxonomy-category', array( 'cnAdminActions', 'processEntryCategory' ), 9, 2 );
// Entry Meta Action
add_action( 'cn_process_meta-entry', array( 'cnAdminActions', 'processEntryMeta' ), 9, 2 );
// Geocode the address using Google Geocoding API.
add_filter( 'cn_set_address', array( 'cnEntry_Action', 'geoCode' ) );
// Result will be either FALSE, on failure, or the entry ID, on success.
$result = cnEntry_Action::add( $entry_data );
}
$entry_data
will be an array containing the data for the entry to be created. Look at the beginning of cnEntry_Action::process()
to see how to build that data array.
Also, address, phones, email and such are repeatable fields in Connections so the data for those need to be an array too. You’ll want to look at the corresponding methods in the class.entry-data.php
file.
Hope that helps you get on your way!