restrict access to link
margaridacarvalho - March 10, 2009 - 10:19
Hi!
I have several images that are linked to different pdf's. What i want to do is to restrict access to anonymous users. I want them to be able to see the images but i don't want them to be able to click the image and consequently see the pdf.
Does anyone can tell how to do this?

permission..
you can do that in admi/user/permissions
sorry
Thanks for your quick reply.
I'm sorry but i can't see how can i do this through user/permissions. I can restrict acess to pages but then anonymous users can't see the images, and i would like them to see them but couldn't click on them. I've tried path access module but i can't seem to put it to work right.
Could private file system and access control configuration be the answer to my problem?
Any other suggestion?
you can also do path access,
you can also do path access, so that the user ends up at an Access Denied page.
Or, alternatively, you can do it in php
<?phpif (in_array('anonymous',$GLOBALS['user']->roles)){?{>
...html tag for link.....
<?php }
?>
<?phpif (in_array('anonymous',$GLOBALS['user']->roles)){?{>
...close link tag.....
<?php }
?>
that way, the image is always produced, but the link tags are inside the php, and don't get printed for anonymous users
mark
thank's for your reply. i
thank's for your reply.
i would like to try the php solution. where do i put the php code?
In the page. Use input format
In the page. Use input format PHP.
--
CiviHosting - Drupal Hosting at its Best
FYI
you need to enable first the PHP Filter under admin/build/modules
I've tried the php code but
I've tried the php code but i'm getting the error "Parse error: parse error in C:\xampp\htdocs\drupal6\includes\common.inc(1648) : eval()'d code on line 4". I know that is a syntax error. The problem is that i don't know that much about php, actually i know very few...
Here is the code that i have in my page:
<p><img src="sites/default/files/imagensprodutoscatalogo/sextavados/sextavados1.png" alt="" /></p>
<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){?{>
<a href="sites/default/files/imagensprodutoscatalogo/produtospdf/din508.pdf">
<?php }
?>
<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){?{>
</a>
<?php }
?>
Can someone tell me where is the error?
<p><img
<p><img src="sites/default/files/imagensprodutoscatalogo/sextavados/sextavados1.png" alt="" /></p>
<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){ ?>
<a href="sites/default/files/imagensprodutoscatalogo/produtospdf/din508.pdf">
<?php }
?>
<?php
if (in_array('anonymous',$GLOBALS['user']->roles)){ ?>
</a>
<?php }
?>
or even cleaner:
<p><img src="sites/default/files/imagensprodutoscatalogo/sextavados/sextavados1.png" alt="" /></p>
<?php
if (in_array('anonymous',$GLOBALS['user']->roles)) {
echo '<a href="sites/default/files/imagensprodutoscatalogo/produtospdf/din508.pdf"> ';
}
?>
<?php
if (in_array('anonymous',$GLOBALS['user']->roles)) {
echo '</a>';
}
?>
--
CiviHosting - Drupal Hosting at its Best
no link for any users
thank you for the quick reply!
I've tried both code suggestions. I don't have the error anymore and the image appears but no link, whether i logged as autenticated or as anonymous user.
what may went wrong?
I just checked your syntax,
I just checked your syntax, not your logic. Try to look for
anonymous user
not just "anonymous"
--
CiviHosting - Drupal Hosting at its Best
Path Access
Check out Path Access http://drupal.org/project/path_access