Hide Users from global Users List

If you want to hide specific users from the global users list (yourdomain.com/primus_user_list/), you can do that with the following code. Add it to your child theme’s functions.php

Get the child theme here: Child Theme

$pn_customizations = new PrimusNoteCustomizations();

add_filter( 'primus.user.list.user_objects', array( $pn_customizations, 'hideAdminUser' ) );
class PrimusNoteCustomizations
{
    /**
     * find the id of the user you want to hide:
     * http://guides.slidervilla.com/2014/04/find-user-id-author-wordpress/
     */

    public function hideAdminUser( $user_objects )
    {
        $ids_to_exclude = array(
            1,
            2
        );

        $allowed_users = array();

        foreach( $user_objects as $user ) {

            if( !in_array( $user->getId(), $ids_to_exclude ) ) {
                $allowed_users[] = $user;
            }

        }

        return $allowed_users;

    }

}

Was this article helpful?

Related Articles

Leave A Comment?