The code you provided looks correct, and it should work as expected. However, if you want to add the ‘give_phone’ option using a filter, you would need to modify the code to include the filter hook and the callback function. Here’s the modified code:
function additional_field($options) {
$options['give_phone'] = __( 'Phone', 'give' );
return $options;
}
add_filter('give_import_donations_options', 'additional_field');
function give_import_donations_options() {
return (array) apply_filters(
'give_import_donations_options',
[
'id' => __( 'Donation ID', 'give' ),
'first_name' => [
__( 'Donor First Name', 'give' ),
__( 'First Name', 'give' ),
__( 'Name', 'give' ),
__( 'First', 'give' ),
],
'last_name' => [
__( 'Donor Last Name', 'give' ),
__( 'Last Name', 'give' ),
__( 'Last', 'give' ),
],
'company_name' => [
__( 'Company Name', 'give' ),
__( 'Donor Company Name', 'give' ),
__( 'Donor Company', 'give' ),
__( 'Company', 'give' ),
],
'country' => __( 'Country', 'give' ),
'notes' => __( 'Notes', 'give' ),
]
);
}
$modified_options = give_import_donations_options();
print_r($modified_options);
Note: Place this code in your theme’s functions.php file or in a custom plugin file and inform me if you have any issues.