Exclude specific authors from this template

Question

I’ve been using this template many years now, but as new admins arrived and they are not writing content, i need their profiles to be removed from the author page.

The code i’m using right now is this i found years ago:

/*
Template Name: Autores
*/

// Get all users order by amount of posts
$allUsers = get_users('orderby=post_count&order=DESC');

$users = array( ) ;

// Remove subscribers from the list as they won't write any articles
foreach($allUsers as $currentUser)
{
    if(!in_array( 'subscriber', $currentUser->roles ))
    {
        $users[] = $currentUser;
    }
}

?>

And then the design code.

I’ve tried to hide the ID 106 (that’s the author ID i’m trying to hied) using this:

/*
Template Name: Autores
*/

// Get all users order by amount of posts
$allUsers = get_users(array('orderby' => 'post_count',
                'order'=>'DESC',
                'exclude' => array(106));

$users = array( ) ;

// Remove subscribers from the list as they won't write any articles
foreach($allUsers as $currentUser)
{
    if(!in_array( 'subscriber', $currentUser->roles ))
    {
        $users[] = $currentUser;
    }
}

?>

But broke the page.

It really would be nice if i just could hide every user that has no post published, i think this would be better than have to hide user by user in the future (or forget to “unhide” some user)

Any sugestions?

Thanks a lot

0
mrgomez 3 years 2020-08-28T04:10:19-05:00 0 Answers 38 views 0

Leave an answer

Browse
Browse