Forked from strangerstudios/my_pmpro_memberslist_extra_cols.php
Last active
December 7, 2019 15:30
-
-
Save kimcoleman/18380bdbe4743cd10ce6b1bf51d39e68 to your computer and use it in GitHub Desktop.
Add a custom column to the Memberships > Members admin page for a user field added via Register Helper using the PMPro hook method.
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 a custom column to the Memberships > Members admin page for a user field | |
* added via Register Helper using the PMPro hook method. | |
* | |
* 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 'Company' Column to Members List Header. | |
function my_pmpro_memberslist_extra_cols_header( $theusers ) { ?> | |
<th><?php _e('Company', 'pmpro');?></th> | |
<?php | |
} | |
add_action( 'pmpro_memberslist_extra_cols_header', 'my_pmpro_memberslist_extra_cols_header' ); | |
// Add 'Company' Column to Members List Rows. | |
function my_pmpro_memberslist_extra_cols_body( $theuser ) { ?> | |
<td> | |
<?php | |
if ( ! empty( $theuser->company ) ) { | |
echo $theuser->company; | |
} | |
?> | |
</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