Display only specific group on member directory page

Permalink 2 users found helpful
Hi there,

I'm not a developer but since I couldn't find a solution based on the UI/system level, I wanted to ask for help here.

Environment:
- Version 8.5.2
- Advanced Permissions NOT activated
- 2 additional member groups created, one being a sub-group of the (both non-administrators)
- Public Profile option TURNED ON

Use case:
I want to add about 100-200 users that are customers of the website owner. They shall be visible to the public on the members page and be able to modify their account data (after login) including some custom attributes like "shop name", "phone number", "website url" and so forth.
The public is not supposed to see their username, instead, a custom "shop name" attribute should be used (also for sorting).

Here's what I'd like to attain and didn't succeed in:

1. On the member directory page show ONLY members of the new groups. Every user that is not inside this group, for example all admins, are supposed to be should be hidden.

2. In the list of members, hide the the username and use a custom attribute "shop name" instead (user name is not relevant to the guests).

I would greatly appreciate any help or hints.

Thank you,
ulix

 
hutman replied on at Permalink Best Answer Reply
hutman
There are a few things that you will need to do for this.

In the Dashboard -> Members -> Attributes set the attributes that you want to display to have "Displayed on Member List." checked.

Create a new file at application/controllers/single_page/members/directory.php with this content (replace GROUP_1_NAME and GROUP_2_NAME with your actual group names

<?php
namespace Application\Controller\SinglePage\Members;
use Concrete\Core\User\Group\Group;
use Concrete\Core\User\UserList;
class Directory extends \Concrete\Controller\SinglePage\Members\Directory
{
    public function on_start()
    {
        parent::on_start();
        $this->requireAsset('css', 'core/frontend/pagination');
        $includeGroups = [
            Group::getByName('GROUP_1_NAME'),
            Group::getByName('GROUP_2_NAME')
        ];
        $this->userList = new UserList();


Copy the file from concrete/single_pages/members/directory.php to application/single_pages/members/directory.php and remove this line

<td class="ccm-members-directory-name"><a href="<?=$user->getUserPublicProfileURL()?>"><?=ucfirst($user->getUserName())?></a></td>


If you now clear your cache you should see the results that you were looking for.
ulix replied on at Permalink Reply
Thank you so much, hutman!
Great support – and such a quick response. What a community!

The filtering works like a charm, admins are not visible any more. I'm just facing a problem regarding the overriding which is done by the new application/single_pages/members/directory.php
It seems it doesn't override the concrete core file, so the user name remains visible in the list.

I cleared the cash (also manually from the cache directory), refreshed the single page template – doesn't make a difference. I think it's a different problem and unrelated with your solution. So I'll continue looking for the cause. Just in case you experienced something similar, I'm happy to learn more.

Thanks again!!
hutman replied on at Permalink Reply
hutman
You don't happen to have a directory.php in your theme anywhere do you?
ulix replied on at Permalink Reply
Oh yes, I do! You are so right – I just totally forgot to check that. The core file looked so much like what I saw in the frontend, that it didn't even come to my mind to check that.
Thanks for pointing in that direction!! You helped me a lot again.

What I did now: I copied the [theme name]/members/directory.php from the theme's package (it's the PIXEL theme) over to a newly created /members directory inside the application/themes/pixel folder. I was expecting it to override the package's file, but it just kind of breaks the layout/design of the members pages.
Am I missing something? Isn't this the right way to override package files any more? Couldn't find any documentation for version 8 on that.
hutman replied on at Permalink Reply
hutman
Unfortunately, as far as I know, there is not a good way to override package theme files, I would just adjust it in place and know if you upgrade you will have to change it again.
ulix replied on at Permalink Reply
Excellent, that did the trick! Once again – thank you very much!!