Forum

Thread tagged as: Question, Forms, Members

Members account with associated file uploads

Hi there.

I am trying to produce a members area for a site where the member can upload various documents that are required before they can hire equipment from my client. The client requires proof of address, identity and insurance.

I have the members section working, and I have a form where they can upload the relevant files. What I am unsure of is how to link those files to the member who uploaded them? I would like to display on the account page an indication if the files have been uploaded and that they are awaiting verification. Then once the member is tagged with 'Verified' display success on their account page.

How can I test for file uploads and connect it with the relevant member? Ideally I would also like to output these files next to the member information in the Perch Admin, at the moment the client will have to look at the members section to get member information, and then look at the forms section to get the files. Can these two be linked?

Many thanks, Rob

Rob Saunders

Rob Saunders 0 points

  • 2 months ago
Drew McLellan

Drew McLellan 2578 points
Perch Support

How are you handling the file uploads?

The file uploads are being handled by perch forms. Is there another option?

Is there a search feature for the members section as well? The client is worried as to how they will find individual members when there are lots in there.

Please could you also shed some light as to why this isnt working. Currently it automatically adds the 'unverified' tag correctly but doesn't remove it when the 'verified' tag is added in the CMS:

if (perch_member_has_tag('verified')) {
                perch_member_remove_tag('unverified');
              } else {
                perch_member_add_tag('unverified');
              };

It is on my main members account page which is the first thing they arrive to after registering. I want to automatically tag all members as 'unverified' when they sign up, but then remove that if they have been tagged as 'verified'. Then if the 'verified' tag has expired I would like them to be retagged with 'unverified'.

Also If I remove the 'verified' tag and refresh the page the output is still as if verified:

<perch:member has-tag="verified">
      <p>You are verified for hiring!</p>
  <perch:else:member>
<p>Unverified</p>
  </perch:member>

However...updating the form on the page seems to make it all work. Why would this be?

Drew McLellan

Drew McLellan 2578 points
Perch Support

updating the form on the page seems to make it all work

Updating which form on which page, sorry?

The member form on the account page:

perch_member_form('profile.html');

Either way, when logging into the account a member who is tagged as 'verified' still has the tag 'unverified' despite:

if (perch_member_has_tag('verified')) {
      perch_member_remove_tag('unverified');
  } else {
      perch_member_add_tag('unverified');
  };

at the top of the page.

Drew McLellan

Drew McLellan 2578 points
Perch Support

If you change a tag, typically it won't take effect until the next page load.

Indeed, but this is not happening. Both tags stay assigned to the member despite multiple page loads, logging in and out of the member account page and refreshing of the admin etc.

Drew McLellan

Drew McLellan 2578 points
Perch Support

But not when submitting one particular form?

I've removed all forms from the page to try and get this functionality working on its own. It still doesn't work within that if statement. However, lets turn this around because I'm not sure that will achieve what I want any way if it requires a reload of the members account page.

I'm trying to find a way to display in the perch admin all the members that are verified, and all the members that are unverified. The client needs to be able to quickly look and see if someone they are hiring to has been checked and verified. Verification tags will have an expiry date so ideally I need the unverified tag to be added to the member on the expiry of the verified tag...is that possible?

Equally, back to my original question...you hinted there was a possible solution to linking files from a form with a member account?

I've been trying a suggestion from another post and its almost working. I'm planning on putting this as a dashboard app so that everytime the client logs into the Perch UI they update all the member tags. So far this removes the 'unverified' tag if a member has the tag 'verified'. But is doesn't add the 'unverified' tag if the user DOES NOT have the 'verified' tag. So close! Verified and unverified are being output to the page correctly via the echo but its just the final member tag not updating. Any idea why not?

  $API = new PerchAPI(1.0, 'perch_members');
  $Members = new PerchMembers_Members($API);
  $members = $Members->all();
  foreach($members as $Member) {

    $verify = new stdClass();
    $unverify = new stdClass();

    $verify->data = array(
      perch_member_remove_tag('unverified')
    );

    $unverify->data = array(
      perch_member_add_tag('unverified')
    );

    if (perch_member_has_tag('verified')) {
        $Member->update_profile($verify);
        echo "verified";
    };

    if (!perch_member_has_tag('verified')) {
      $Member->update_profile($unverify);
      echo "unverified";
    };

  }
Drew McLellan

Drew McLellan 2578 points
Perch Support

perch_member_add_tag() and perch_member_remove_tag() act on the current authenticated member account. They won't work in this context.

I think you want to use $Member->add_tag() instead.

Great thank you, that is adding the tags. How do you remove a tag? $Member->remove_tag() doesn't do it. The if statement still doesn't seem to work, it adds tags regardless if true or not:

if (!perch_member_has_tag('verified')) {
      $Member->add_tag('unverified');
      echo "unverified";
    };

Alternatively, is there a way in the perch admin to display all members who dont have a tag? that would solve this issue completely. So view everyone without the tag 'verified'.

Drew McLellan

Drew McLellan 2578 points
Perch Support

Adding a tag removes the existing tag and adds the new one. If you add the tag you want to remove, setting an expiry of the current time (or a time in the past) that will remove the tag.

That doesn't seem to work? My page looks like so:

<?php
  $perch = $_SERVER["DOCUMENT_ROOT"];
  $perch .= "/admin/runtime.php";
  include_once($perch);


  $API = new PerchAPI(1.0, 'perch_members');
  $Members = new PerchMembers_Members($API);
  $members = $Members->all();
  foreach($members as $Member) {
    $Member->add_tag('unverified', '2018-01-01');
  }

?>

The tag 'unverified' stays attached in the Perch UI.

Drew McLellan

Drew McLellan 2578 points
Perch Support

The expiry date is the third argument.

Thank you, we are getting there step by step. How would one test for members with a certain tag? I've tried:


foreach($members as $Member) { if ($Member->has_tag('verified')) { $Member->add_tag('unverified', true, '2016-01-01'); }; }

and

$members->get_by_tag_for_admin_listing('unverified');

I can get a list of all the tags with:

$Tags = new PerchMembers_Tags($API);

But not sure how to work out if a member has a tag assigned?

Drew McLellan

Drew McLellan 2578 points
Perch Support

get_by_tag_for_admin_listing() will get members by tag, but it's for admin purposes, not for use on the site front end.

So how would you get either a list of members tags or a list of members with a certain tag?

Drew McLellan

Drew McLellan 2578 points
Perch Support

In what context are you trying to get the list? In an app, or as part of your site?