Is it possible to Only Show a specific User role in Front-End?

This topic contains 2 replies, has 3 voices, and was last updated by  Patrik 4 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #4662

    Julian Laibach
    Free User

    Hello, is it possible to not just exclude Users by ID? I wonder if it´s possible to completely hide all users with the Role as “Admin”. If there is anyone who could solve this problem I would also pay for this modification of the Plugin.

    Greetings Julian

    #4668

    Alex Rollin
    Moderator
    Post count: 27815

    Not at this time, but we will keep your suggestion in mind for future versions. We have some role related features coming later in the year, but, right now, since we don’t have other role related features we are saving up ideas for after that release.

    #4669

    Patrik
    Moderator
    Post count: 1971

    Hi,

    Can you try the following code in functions.php of currently active theme and let me know if it works for you or not?

    
    add_filter('uwp_excluded_users_from_list', 'uwp_excluded_users_from_list_cb', 10, 1);
    function uwp_excluded_users_from_list_cb($exclude_users){
        $admins = get_users( array( 'role' => 'administrator', 'fields' => array('ID') ) );
        $admins = wp_list_pluck( $admins, 'ID' );
        if(!empty($admins)){
            $exclude_users = array_merge($exclude_users, $admins);
        }
    
        return $exclude_users;
    }
    

    You can change the role parameter as per your requirements.

    Regards,
    Patrik

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket