Last active
February 12, 2016 10:14
-
-
Save sectsect/9a415394ce0d2c340781 to your computer and use it in GitHub Desktop.
Remove "administrator" user from "get_users()" on wordpress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function remove_administrator($users) | |
{ | |
foreach ($users as $key => $user) { | |
$cap = reset($user->roles); | |
if ($cap === 'administrator') { | |
unset($users[$key]); | |
} | |
} | |
return $users; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = get_users(array( | |
'orderby' => 'ID', | |
'order' => 'ASC' | |
)); | |
$users = remove_administrator($users); | |
foreach ($users as $user): | |
?> | |
<a href="<?php echo get_author_posts_url($user->ID); ?>"> | |
<?php $aID = get_the_author_meta('ID', $user->ID); ?> | |
<?php echo $user->display_name; ?> | |
</a> | |
<?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment