Hi @fceadmin,
The best way to add a field to the Campaigns export is with the Campaign Fields API. Here’s some sample code showing how to do that:
add_action( 'init', function() {
$field = new Charitable_Campaign_Field( 'my_meta_field', array(
'label' => 'My Meta Field',
'admin_form' => false,
'show_in_export' => true,
'email_tag' => false,
'value_callback' => function( Charitable_Campaign $campaign ) {
return get_post_meta( $campaign->ID, 'my_meta_field', true );
},
) );
charitable()->campaign_fields()->register_field( $field );
} );
The ‘label’ will be used as the export column header. ‘show_in_export’ needs to be true to have it added to the Campaign export. Finally, ‘value_callback’ should be a function that returns the value of the post meta field. This function will receive a Charitable_Campaign object as the first parameter. The example above gets the value of a post meta field with a key of ‘my_meta_field’.
Hope that helps! If you’re not sure how to add code like this to your site, check out our guide here:
https://www.wpcharitable.com/documentation/3-ways-to-add-code-customizations-to-your-site/
Cheers,
Eric