Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dwanjuki/a54813c3e05142c25a8b2865be545c2c to your computer and use it in GitHub Desktop.
Save dwanjuki/a54813c3e05142c25a8b2865be545c2c to your computer and use it in GitHub Desktop.
Include approval status in the Members List export CSV
<?php // copy from below
/**
* Include membership approval status in the Members List export CSV
*
* 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/
*/
function my_pmpro_members_list_csv_approval_column( $columns ) {
$columns["approval"] = "my_pmpro_members_list_column_approval";
return $columns;
}
add_filter( 'pmpro_members_list_csv_extra_columns', 'my_pmpro_members_list_csv_approval_column' );
function my_pmpro_members_list_column_approval( $user ) {
if ( ! class_exists( 'PMPro_Approvals' ) ) {
return;
}
$approval_status = PMPro_Approvals::getUserApprovalStatus( $user->ID, $user->membership_id );
if ( $approval_status !== NULL ) {
return ucfirst( $approval_status );
} else {
// The member existed before Approval was required
return '-';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment