Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created October 12, 2020 18:07
Show Gist options
  • Save ronalfy/8e3e7d4e06dd91be42d55917a91ee1e2 to your computer and use it in GitHub Desktop.
Save ronalfy/8e3e7d4e06dd91be42d55917a91ee1e2 to your computer and use it in GitHub Desktop.
PMPro - Add Notes to Order Columns in Admin and CSV
<?php
/**
* Adds a notes tab in the admin area and in the order CSV export.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
* Add donation to Orders page and CSV export
*/
function my_pmprodon_init() {
add_action('pmpro_orders_extra_cols_header', 'my_pmpro_orders_extra_cols_header');
add_action('pmpro_orders_extra_cols_body', 'my_pmpro_orders_extra_cols_body');
add_action('pmpro_orders_csv_extra_columns', 'my_pmpro_orders_csv_extra_columns');
}
add_action('init', 'my_pmprodon_init');
function my_pmpro_orders_extra_cols_header() {
echo '<th>' . __('Notes', 'paid-memberships-pro') . '</th>';
}
function my_pmpro_orders_extra_cols_body($order) {
echo '<td>' . wp_kses_post( $order->notes ) . '</td>';
}
function my_pmpro_orders_csv_extra_columns($columns) {
$columns['notes'] = 'my_pmpro_orders_csv_notes';
return $columns;
}
add_filter('pmpro_orders_csv_extra_columns', 'my_pmpro_orders_csv_extra_columns');
function my_pmpro_orders_csv_notes($order) {
return $order->notes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment