06/10/2016 at 4:51 pm
#379112
Guest
Hi Steven –
Does make sense. I actually did exactly that & the fields are still added the Custom Field area, not the custom field metabox :( Find my code below (added to functions.php).
/* Register a custom metabox with text field on the connections add entry page */
add_action( 'cn_metabox', 'my_connections_custom_metabox_and_text_fields' );
function my_connections_custom_metabox_and_text_fields() {
$atts = array(
'title' => 'Memorial Locations', // Change this to a name which applies to your project.
'id' => 'memorial_locations', // Change this so it is unique to you project.
'context' => 'normal',
'priority' => 'core',
'fields' => array(
array(
'name' => 'Superintendent\'s Honored Star Case', // Change this field name to something which applies to you project.
'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name.
'id' => 'sup_honored_star_case', // Change this so it is unique to you project. Each field id MUST be unique.
'type' => 'text', // This is the field type being added.
'size' => 'regular', // This can be changed to one of the following: 'small', 'regular', 'large'
)
//...more fields here
),
);
cnMetaboxAPI::add( $atts );
}
/* CSV Importer Custom Meta Fields*/
add_filter( 'cncsv_map_import_fields', 'cncsv_import_meta_fields_options' );
function cncsv_import_meta_fields_options( $fields ) {
echo print_r($fields);
$fields['sup_honored_star_case'] = 'Memorial Locations | Superintendent\'s Honored Star Case';
//....more fields here
return $fields;
}
add_action( 'cncsv_import_fields', 'cncsv_import_meta_fields_import', 10, 2 );
function cncsv_import_meta_fields_import( $id, $row ) {
$sup_honored_star_case = isset( $row->sup_honored_star_case ) ? $row->sup_honored_star_case : '';
//...more fields here
cnEntry_Action::meta(
'update',
$id,
array(
array(
'key' => 'Superintendent\'s Honored Star Case',
'value' => $sup_honored_star_case
)
//......more fields here
)
);
}
