Forum

Thread tagged as: Question, Members

Add member tag on file download.

Hi,

Wondering if anyone has thought about this before... The client would like people to register to download files research pdfs from their site. When a visitor registers, I am creating a member record in perch members.

When they register, they see a button which allows them to download the document. All of this is working fine.

This is where I'm running into problems... I would like to add a member tag of the document's name slug when they click that button, but I'm not sure what the code would look like.

Any help would be much appreciated.

-- Monty

Monty Lewis

Monty Lewis 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It would look like:

perch_member_add_tag('file_name');

Right, but I need the button to still be the button that downloads the file. What I ended up doing was have the button call download-inquiry.php, passing in the location of the file and file name slug. So the tag gets added by this file and then advances to the download. Does that seem like a good way to handle it or is there a much easier way? download-inquiry.php is:

<?php
ob_start(); // ensures anything dumped out will be caught
PerchSystem::set_var('doc', perch_get('d'));
PerchSystem::set_var('loc', perch_get('l'));
$doc = PerchSystem::get_var('doc');
$loc = PerchSystem::get_var('loc');
perch_member_add_tag($doc);
header( "Location: $loc" );
?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Why not put it right before your call to perch_members_secure_download() ?

I don't know the answer to that question... this is an existing stock of documents whose download access was previously managed by perch but access was handled by HubSpot integration. I'lm replacing the HubSpot component with Perch Members app... So not sure...

It would mean moving all the documents to a new location, right?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't know without knowing how it's currently structured.

Right. I need to read through member downloads.

Would I still be able to show the documents to the public if I did it through the member's app?

This one is now on me. I'll mark as solution. Thanks!