Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Created December 12, 2024 15:24
Show Gist options
  • Save kimcoleman/df5cef32541000c8eb1a31498b61bdef to your computer and use it in GitHub Desktop.
Save kimcoleman/df5cef32541000c8eb1a31498b61bdef to your computer and use it in GitHub Desktop.
Custom recipe to add columns to the Members List. Used for the Condo Owner's Association Demo at https://coa.pmproplugin.com/
<?php
function my_coa_demo_pmpro_add_memberslist_cols( $columns ) {
$columns['unit'] = 'Unit';
$columns['condo_status'] = 'Condo Status';
$columns['household_count'] = 'Household Members';
$columns['household_pet_count'] = 'Household Pets';
$columns['parking_spot_number'] = 'Parking Spot Number';
return $columns;
}
add_filter( 'pmpro_manage_memberslist_columns', 'my_coa_demo_pmpro_add_memberslist_cols' );
function my_coa_demo_pmpro_fill_memberslist_cols( $colname, $user_id ) {
if ( in_array( $colname, array( 'unit', 'condo_status', 'household_count', 'household_pet_count', 'parking_spot_number' ) ) ) {
echo esc_html( get_user_meta( $user_id, $colname, true ) );
}
}
add_filter( 'pmpro_manage_memberslist_custom_column', 'my_coa_demo_pmpro_fill_memberslist_cols', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment