Forked from greathmaster/pmpro-member-number-csv.php
Last active
September 21, 2022 12:39
-
-
Save kimwhite/9764301c7f2684d302272e4208682509 to your computer and use it in GitHub Desktop.
Show member number in Members List and Members List CSV export.
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 // do not copy this line. | |
/** | |
* This recipe Shows member number in Members List and Members List CSV export | |
* Requires PMPro Member Number Gist: | |
* https://github.com/strangerstudios/pmpro-snippets-library/blob/dev/frontend-pages/generate-unique-membership-number.php | |
* | |
* 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_extra_columns($columns) | |
{ | |
$columns["member_number"] = "my_extra_column_member_number"; | |
return $columns; | |
} | |
add_filter("pmpro_members_list_csv_extra_columns", "my_pmpro_members_list_csv_extra_columns", 10); | |
function my_extra_column_member_number($user) | |
{ | |
if(!empty($user->metavalues->member_number)) | |
{ | |
return $user->metavalues->member_number; | |
} | |
else | |
{ | |
return ""; | |
} | |
} | |
function my_pmpro_memberslist_extra_cols_header() | |
{?> | |
<th><?php _e('Member Number', 'pmpro');?></th><?php | |
} | |
add_action("pmpro_memberslist_extra_cols_header", "my_pmpro_memberslist_extra_cols_header"); | |
//columns | |
function my_pmpro_memberslist_extra_cols_body($theuser) | |
{?> | |
<td><?php | |
if(!empty($theuser->member_number)) | |
{ | |
echo $theuser->member_number; | |
}?> | |
</td><?php | |
} | |
add_action("pmpro_memberslist_extra_cols_body", "my_pmpro_memberslist_extra_cols_body"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment