Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimcoleman/18380bdbe4743cd10ce6b1bf51d39e68 to your computer and use it in GitHub Desktop.
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.
<?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