I have pdf files on my website where I want to open the pdf files only if the user is logged in, otherwise, it should redirect to the login page if they click the pdf file. I have the code to display the pdf file as,
<a href="sw/events/pdf/<?php echo $event['eventDocument'] ?>" target="_blank"><img src="img/pdf.png" alt="pdf-icon"></a>
Any help will be very much appreciated!! thanks!!
you can do:
if (user is logged)
{
echo '<a href="sw/events/pdf/' .$event['eventDocument'] .'"target="_blank"><img src="img/pdf.png" alt="pdf-icon"></a>';
}
else echo '<a href="path/to/login" ><img src="img/pdf.png" alt="pdf-icon"></a>';
but you should do it before template render:
$pdf_path = '/path/to/login';
if ( user is logged )
$pdf_path = 'sw/events/pdf/'.$event['eventDocument'].'';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.