Created
June 11, 2024 12:28
-
-
Save dwanjuki/a54813c3e05142c25a8b2865be545c2c to your computer and use it in GitHub Desktop.
Include approval status in the Members List export CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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