Last active
September 22, 2018 14:56
-
-
Save dparker1005/c483978636c1dfac21c9a938b5c60ede to your computer and use it in GitHub Desktop.
Adds the next billing date for a recurring membership to the Members List page of Paid Memberships Pro and the CSV file generated by it.
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 | |
/* | |
* To add 'Next Billing Date' to Members List | |
*/ | |
//Add 'Next Billing Date' Column to Members List Header | |
function my_pmpro_memberslist_extra_cols_header($theusers) | |
{ | |
?> | |
<th><?php _e('Next Billing Date', 'pmpro');?></th> | |
<?php | |
} | |
add_action('pmpro_memberslist_extra_cols_header', 'my_pmpro_memberslist_extra_cols_header'); | |
//Add 'Next Billing Date' Column to Members List Rows | |
function my_pmpro_memberslist_extra_cols_body($theuser) | |
{ | |
?> | |
<td> | |
<?php | |
if(!empty($theuser->data->ID)){ | |
$nextPayment = pmpro_next_payment($theuser->data->ID, 'success', 'date_format'); | |
if($nextPayment == "") | |
echo "None"; | |
else | |
echo pmpro_next_payment($theuser->data->ID, 'success', 'date_format'); | |
} | |
?> | |
</td> | |
<?php | |
} | |
add_action('pmpro_memberslist_extra_cols_body', 'my_pmpro_memberslist_extra_cols_body'); | |
/* | |
* To add 'next_billing_date' to CSV Export | |
*/ | |
//add the column to the export | |
function my_pmpro_members_list_csv_extra_columns ( $columns ) { | |
$columns["next_billing_date"] = "my_pmpro_add_bill_date_to_csv"; | |
return $columns; | |
} | |
add_filter( 'pmpro_members_list_csv_extra_columns', 'my_pmpro_members_list_csv_extra_columns', 10 ); | |
//call back to get the column a value | |
function my_pmpro_add_bill_date_to_csv( $user ) { | |
//this is an example to retrive user meta | |
$column_value = pmpro_next_payment($user->ID, 'success', 'date_format'); | |
if($column_value=="") | |
$column_value = "None"; | |
return $column_value; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment