Last active
July 14, 2017 13:06
-
-
Save dparker1005/4a5c17ca0bc028197f7a48c671345050 to your computer and use it in GitHub Desktop.
Adds the 'import membership enddate' field 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 use this code, add it to a PMPro Customizations Plugin | |
// https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
// | |
// To add 'Import Membership Enddate' to Members List | |
// | |
//Add 'Import Membership Enddate' Column to Members List Header | |
function my_pmpro_memberslist_extra_cols_header($theusers) | |
{ | |
?> | |
<th><?php _e('Import Membership Enddate', 'pmpro');?></th> | |
<?php | |
} | |
add_action('pmpro_memberslist_extra_cols_header', 'my_pmpro_memberslist_extra_cols_header'); | |
//Add 'Import Membership Enddate' Column to Members List Rows | |
function my_pmpro_memberslist_extra_cols_body($theuser) | |
{ | |
?> | |
<td> | |
<?php | |
if(!empty($theuser->data->ID)){ | |
echo(get_user_meta($theuser->ID, 'import_membership_enddate', true)); | |
} | |
?> | |
</td> | |
<?php | |
} | |
add_action('pmpro_memberslist_extra_cols_body', 'my_pmpro_memberslist_extra_cols_body'); | |
// | |
// To add 'Import Membership Enddate' to CSV Export | |
// | |
//add the column to the export | |
function my_pmpro_members_list_csv_extra_columns ( $columns ) { | |
$columns["import_membership_enddate"] = "my_pmpro_import_membership_enddate_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_import_membership_enddate_to_csv( $user ) { | |
//this is an example to retrive user meta | |
return get_user_meta($user->ID, 'import_membership_enddate', true); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment