Thank you so much!!!
Just in case anyone else wants to use this, here’s what I did.
I added it as a plugin, but when I activated it it threw an undefined function fatal error on the line add_action( bp_core_admin_hook(), ‘artisantopia_admin_menus’ );
So I played about with it and customised it a bit, and this is what I ended up with. It’s working well for me, but if you see anything that could be improved please let me know!
<?php
/*
Plugin Name: BuddyDrive Extension
Description: Adds user name in BuddyDrive admin and displays those users that have not uploaded anything. Used for credentials system.
Version: 1.0
*/
/** Add username next to avatars **/
function mmbk_show_username( $avatar = '', $user_id = 0 ) {
if( !empty( $user_id ) )
$avatar .= '<span class="mmbk-user-name"> ' . bp_core_get_username( $user_id, true ) . '</span>';
return $avatar;
}
add_filter( 'buddydrive_get_show_owner_avatar', 'mmbk_show_username', 10, 2 );
/** builds a new Admin Menu to list the users that didn't upload any BuddyDrive file **/
function mmbk_no_credentials() {
global $wpdb;
if( !function_exists( 'buddydrive_get_file_post_type') )
return false;
$people_nofiles = $wpdb->get_results(
$wpdb->prepare(
"SELECT u.ID, u.user_nicename, u.user_email
FROM {$wpdb->users} u WHERE u.ID NOT IN
( SELECT p.post_author FROM {$wpdb->posts} p WHERE u.ID = p.post_author AND p.post_type = %s GROUP BY p.post_author )",
buddydrive_get_file_post_type()
)
);
?>
<div class="wrap">
<h2>People with no files</h2>
<table class="widefat">
<thead>
<tr><th>ID</th><th>Username</th><th>Email</th></tr>
</thead>
<tbody>
<?php foreach( $people_nofiles as $people ) :?>
<tr>
<th><?php echo intval( $people->ID ) ;?></th>
<th><?php echo sanitize_text_field( $people->user_nicename ) ;?></th>
<th><?php echo sanitize_email( $people->user_email ) ;?></th>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr><th>ID</th><th>Username</th><th>Email</th></tr>
</tfoot>
</table>
</div>
<?php
}
function mmbk_admin_menus() {
if( !function_exists( 'buddydrive' ) )
return;
add_menu_page(
'No Credentials',
'No Credentials',
'manage_options',
'mmbk-no-credentials',
'mmbk_no_credentials'
);
}
add_action( 'network_admin_menu', 'mmbk_admin_menus' );
?>