Thread tagged as: Question, Problem, Members

Client Area using tags or members email address - any suggestions?

Hi All,

I think I may have confused things with a previous thread on this topic, so I am reposting.

I am trying to create a client area using the members app so that different clients can see their documents. Client A logs in and see's Client A documents. Client B logs in and sees Client B documents.

I have this working by creating a client collection, the client has an email address field. This email address corresponds to an email address assigned to the client in the members app. When the client logs in I get their email address using perch_member_get('email') and assign it to a variable. I then use this variable as the filter for the collection comparing it to the email address field in the client collection item.

I was looking into ways of making this more flexible and allowing multiple email addresses for the same client, by maybe retrieving the tag assigned to the logged in member and somehow comparing that to an associated tag field in the client collection item.

I wasn't sure if

  • I can retrieve the tag from a logged in member, I've looked in to the API and couldn't see it.

  • How I would then compare this to a "client tag" field in my collection. I tried to use "each" callback in the collection but how do you access anything returned from the callback to be used in code after the loop, if that makes sense?

For reference I tried accessing member info as follows

       $memberID = perch_member_get('id'); // get our Member ID

                    $Member = $Members->find($memberID); // Retrieve our Member object by passing memberID
                    $member_details = $Member->to_array();

perch_collection('clients', array( 'each' => function($client) { process as necessary, then return the modified array return $client['clientTag']; }, ));

and I wanted to do some kind of matching of the member tag against clientTag and then show the relevant client documents by filtering the collection by clientTag. Admittedly I am not a PHP expert so I wasn't sure if my approach makes sense or I am completely bonkers!

If this can't be achieved with a tag field as suggested, is there anyway I can retrieve an array of email addresses from a repeater in the client collection and then use this to filter the collection appropriately?

Many thanks

Lee Goodman

Lee Goodman 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

In an each callback, you need to return the item you were given. So in this instance where you've been handed $client, you need to modify it and then return the entire $client item. Returning $client['clientTag'] will result in all the other properties not being available in the template.

Hi Lee,

Did you get this working in the end? I am trying to implement something similar for a client login area for my website.



Hi Mike,

Yes I have this working beautifully :-)

Give me a shout if you need a hand.


Thanks Lee!

Were you using Runway? I am in vanilla Perch, and think I may need to switch as I am not sure how to organise the individual client information in a page-independent way

I've done it in both. Are you in the UK?

Yep I am in the UK, basking in the Shropshire sunshine (not) :)

I think I need to check against email address but am not really sure how to go about it

If you are using Perch.

Install your members app as required. When a member is registered you add an email address.

Create your page as required and select your template, in your page you need to create custom content. In my example it is called clients.
You will need a template for that custom content, in my case I use a field where I enter an email address that matches the registered clients email address, and also a repeater for the downloadable documents.

My content template looks like this

<perch:content id="emailWithAccess" type="text" label="Email Address" required="true" title="true" help="Same email as used to register in members app"  suppress="true"/>
<ul class="list-group">
    <perch:repeater id="clientSecureDownLoads" label="Add documents for this client" divider-before="Documents">
        <li class="list-group-item">
            <a href="<perch:content id="clientfile" type="file" label="File" order="2" bucket="secure" />">
                <i class="fa fa-chevron-right"></i>
                <perch:content type="text" id="fileDesc" label="Title" order="1" required="true" title="true" />
                <span class="badge"><perch:content id="clientDocumentType" type="select" label="Select Document Type" options="Word|doc, Excel|xls, Adobe PDF|pdf" allowempty="false" required="true" /></span>

Then in your page template you will have the relevant page functions, so my page looks like so

<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php'); // create our clients content for downloads perch_content_create('Clients', array( 'template' => 'clients_document_list.html', 'multiple' => true, 'edit-mode' => 'listdetail', 'searchable' => 'false' )); perch_layout('/global/'); ?> <!-- Main --> <div id="main"> <?php perch_content('Contact No'); ?> <?php perch_layout('global/global.nav'); ?> <?php perch_content('Banner'); ?> <section class="content-half"> <div class="container space-large"> <div class="row"> <div class="col-sm-7"> <?php if (perch_member_logged_in()) { $memberEmail = perch_member_get('email'); // get our email to compare ?> <div class="client-intro"> <h4>Welcome to Agile BI <?php echo perch_member_get('first_name') ?></h4> </div> <?php perch_content_custom('Clients', array( 'template'=>'clients_document_list.html', 'filter'=>'emailWithAccess', 'match'=>'eq', 'value'=>$memberEmail, )) ?> <?php }else{ perch_members_login_form(); } ?> </div> <?php perch_layout('clients/side-bar'); ?> </div> </section> </div> <!-- /#main --> <?php perch_layout('/global/global.bottom'); ?>

You will also need to ensure your buckets are set up, and you have a page for the download.

Hope this helps?

Ah that's brilliant thanks Lee, I understand what you are doing. Won't have a chance to implement this until later in the week but that looks really good

No worries, glad I could help. I've got my next challenge with members app, creating an availability calendar that members can update. Yikes!!!

Well that's interesting - my next project needs one of those! Availability for Supply Teachers for a teaching agency.

Best of luck with it - I will be kicking mine off in the next couple of weeks, my email is if you want to perhaps talk anything over

Hah Really - mine is exactly the same requirement for exactly the same client type

Eagle River!

No but another teacher supply agency in the South :-) I am waiting to hear if it is going ahead, but I have a solution in mind but would be interested to hear if you have any ideas how to implement it.


I am just at the wireframing stage at the moment. They also want an integration for digital signing of timesheets, but concentrating on the availability calendar first and then will be expanding on that. Will let you know how I get on :)

Hi Lee,

Hope all is well. How are you getting on with the supply agency site? I am working through the wireframing with the designer at the moment, going ok so far. Think it will end up possibly being a custom app based on Members

Hey Michael,

I am still waiting to hear whether the project is going ahead, keen to see what solution you come up with :-)