Hi Bert,
Currently my plugin only supports tables that are in WordPress Core. There is not an option to select another table, like the one BuddyPress has added.
Unfortunately my plugin can not help you with this at this time. I will make a note of it so I will give it another look for perhaps a feature release.
What you could do in the meanwhile is place this piece of code in your theme’s functions.php.
Make sure you change the $field_name value to your field title that you want to display:
function modify_user_table_row( $val, $column_name, $user_id )
{
// edit this part
$field_name = 'fill in the title of your custom buddyPress user field';
// stop editing
if ( 'buddypress_field' == $column_name ) {
$val = xprofile_get_field_data( $field_name, $user_id );
}
return $val;
}
add_filter( 'manage_users_custom_column','modify_user_table_row',10,3);
function add_my_custom_buddypress_user_column( $column)
{
$column['buddypress_field'] = 'buddypress_field';
return $column;
}
add_filter( 'manage_users_columns', 'add_my_custom_buddypress_user_column' );
Hope this helps you on your way 🙂
Tobias
Thread Starter
bkng
(@bkng)
Great and thanx for the info. Will try it out.
Great plugin BTW.
Thread Starter
bkng
(@bkng)
Hi there and it works like a charm.
Now im trying to figure out how to add another second field form the sam table. (And then ill stop 🙂
But i cannot seem to figure out wich code to change.
Sure would appreciate your help.
Bert
Great. For two columns use the following:
function modify_user_table_row( $val, $column_name, $user_id )
{
$field_name = 'fill in the title of your custom buddyPress user field'; // edit this value
$field_name2 = 'fill in the title of your custom buddyPress user field'; // edit this value
if ( 'buddypress_field' == $column_name ) {
$val = xprofile_get_field_data( $field_name, $user_id );
}
if ( 'buddypress_field2' == $column_name ) {
$val = xprofile_get_field_data( $field_name2, $user_id );
}
return $val;
}
add_filter( 'manage_users_custom_column','modify_user_table_row',10,3);
function add_my_custom_buddypress_user_column( $column)
{
$column['buddypress_field'] = 'Column title goes here'; // you can edit this value
$column['buddypress_field2'] = 'Column title goes here'; // you can edit this value
return $column;
}
add_filter( 'manage_users_columns', 'add_my_custom_buddypress_user_column' );