We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Members

Output a file to download to specific members


We have an issue regarding the members app and trying to create a way to allow them to download files specifically for a member.

I've added the following to members.html:

<perch:members type="text" id="first_name" label="First name" listing="true" order="1" />
<perch:members type="text" id="last_name" label="Last name" listing="true" order="2" />
<perch:members type="file" id="quote_pdf" label="Quote" listing="true" order="3" />

As you can see the last of these is type "file", and now under a specific member we can upload a file, in this case a quote personalise to them.

The issue is we cannot find a way to output that in the members profile page or any page once that member is logged in.

We have tried:

<?php perch_member_form('quotes.html'); ?>

That directs to a simple html file with:

<perch:members type="file" id="quote_pdf" label="Quote" listing="true" order="3" />

But this ends up blank, similarly, we tried the get function:

<?php echo perch_member_get('quote_pdf'); ?>

But my understanding is this only works with a string. Is there any known way to output a file download link?

Many thanks

Wayne Hooper

Wayne Hooper 6 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you looked at this: https://docs.grabaperch.com/addons/members/examples/downloads/

Also the example download.php file that ships with the app.

Hi Drew - I did look at that, but it seemed to me it was for creating a secure area for uploading PDFs only accessible to members logged in, but not files directed at specific members if that makes sense.

For example, we want to upload a quote to a member through their member details in the perch dashboard, but no other member will be able to see that file. Is that possible with secure downloads? We're not concerned about the security so much on these files, since they won't contain anything that requires that, but do need them directed to a member specifically...

I cannot see anything in these files that will output a file added to the member, unlesss I'm missing something?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Isn't it the same thing, except you're testing on a tag or email address or similar?

Hmm - I may need to take a step back on this... I've tried using the secure downloads that ships with the members app to get anb idea of how that works,but also running into issues there.

When I try to dive an option to download the file using:

<?php perch_members_secure_download('my-file.pdf', 'secure', false); ?>

I just get the raw file code all over the page, instead of a link to download it.

Any idea what could cause this?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That method delivers the file. It won't output a link. If you need a link, put it at the stage before, linking to a file that invokes that function.