Created
April 23, 2024 12:42
-
-
Save dwanjuki/9d72bb65af514f7d2b66e47be1a09411 to your computer and use it in GitHub Desktop.
Add Initial Payment column to PMPro v3 Members List Export CSV
This file contains hidden or 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 | |
| /** | |
| * Add Initial Payment to 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/ | |
| * | |
| */ | |
| // add the initial_payment column to the export | |
| function my_pmpro_members_list_csv_extra_columns( $columns ) { | |
| $columns["initial_payment"] = "my_pmpro_members_list_initial_payment_column"; | |
| return $columns; | |
| } | |
| add_filter( 'pmpro_members_list_csv_extra_columns', 'my_pmpro_members_list_csv_extra_columns', 10 ); | |
| // call back to get the initial payment amount | |
| function my_pmpro_members_list_initial_payment_column( $user ) { | |
| $subscriptions = PMPro_Subscription::get_subscriptions_for_user( $user->ID, $user->membership_id ); | |
| $initial_payment = empty( $subscriptions ) ? '' : $subscriptions[0]->get_initial_payment(); | |
| return $initial_payment; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment