Hiding IDs 1-9
Quote from proteus61 on August 5, 2018, 6:53 amHi – 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
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
Quote from Asgaros on August 13, 2018, 6:36 amHello @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
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:
Quote from proteus61 on August 14, 2018, 5:18 pmWisely 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!
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!
Quote from Greggk on June 18, 2019, 2:50 amI 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 🙂
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 🙂
Quote from Asgaros on June 18, 2019, 4:02 pmHello @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')))
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')))