Forum breadcrumbs – You are here:Asgaros Support ForumSupportHiding IDs 1-9
Please or Register to create posts and topics.

Hiding IDs 1-9

Hi – I wish to hide IDs 1-9 which are Administrators and test IDs.  These IDs do not partake in the forum/blogs/community and I have already hid them from Buddypress.  I wrote a small snippet to hide the users from Asgaros Forum as well, yet, before I actually implement it, I wonder if I am going to break anything and if there is a better way to code it.

in the \wp-content\plugins\asgaros-forum\includes\forum-memberslist.php – after line 83 I added

line 83 — $allUsers = get_users(array(‘fields’ => array(‘ID’, ‘display_name’)));

my snippet – // Filter out IDs 1-9 ( Admins and reserved )
for ($z = 0; $z < 10; $z++) {
if(($key = array_search($z, array_column($allUsers, ‘ID’))) !== false) {
unset($allUsers[$key]);
$allUsers = array_values($allUsers);
}
}

Your review and advise highly appreciated

Thanks – Proteus

Hello @proteus61

This looks fine but I think it would be more performant if you use the exclude-parameter of the get_users function directly so you dont need to loop through all of them. Please check out the function documentation here:

https://codex.wordpress.org/Function_Reference/get_users

proteus61 has reacted to this post.
proteus61
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Wisely put – indeed it would be more efficient using the exclude parameter – I modified line 83 as follows:

$allUsers = get_users(array(‘exclude’ => range(1,9), ‘fields’ => array(‘ID’, ‘display_name’)));

Again, Thank you!

Asgaros has reacted to this post.
Asgaros

I was looking for exactly this, has it changed since last year? I tried using the code, but it is not hiding the administrators.  It would be nice to be able to hide the administrator, no one needs to know the wordpress admin 🙂

Hello @greggk

Unfortunately, not yet, but it is on my todo-list:

https://github.com/Asgaros/asgaros-forum/issues/196

If you want to apply the code above, please keep in mind that you have to change the ID-value which is the user-ID of your administrator-account, for example (users with the ID 13 and 37):

get_users(array('exclude' => array(13, 37), 'fields' => array('ID', 'display_name')))

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!