[support] Hide ckk field to anonymous user

Dale McGladdery torelad at gmail.com
Fri Nov 30 18:13:25 UTC 2007


The "standard" method for testing if the user is anonymous is testing
$user->uid. If the value is 0, it's the anonymous user, so you can
treat it like a boolean. I don't know if $user->name is always an
empty string for anonymous user, so it may be ok. However, you're
definitely safer going with the group!

Doing the check_plain will make the cck value safe.

Depending on how you've retrieved $node, there should also be a
$node->field_informacio[0]['view']. 'value' is the raw value, 'view'
is the raw value after cck has applied formatting. For example, if you
have a text field set to 'Plain text', the raw value is whatever the
user entered and the view value is filtered to plain text. As long as
you have the input format set up correctly, the output is safe. So if
your cck fields are set up appropriately, you can save yourself some
work.


On Nov 30, 2007 7:52 AM, Marolijo - Pol maresma <marolijo at yahoo.es> wrote:
> Thank's but I tried it and doesn't work form me under Drupal5.3.
> When I select the permissions under access control and put the field on
> Contemplate's Body it allways apear on the node display.
>
> I found a simply solution because I only wanna control if the user is
> registered, put it on the template's body:
>
> <?php
> global $user;
> if ($user->name<>''){
>     print check_plain($node->field_informacio[0]['value']);
> };
> ?>
>
> Is it secure?
>
> Thank's for all. Gràcies! ;-)
>
> -----Mensaje original-----
> De: support-bounces at drupal.org [mailto:support-bounces at drupal.org] En nombre
> de Walter Garcia-Fontes
> Enviado el: divendres, 30 / novembre / 2007 13:56
> Para: support at drupal.org
> Asunto: Re: [support] Hide ckk field to anonymous user
>
>
> Yes, the module is called "CCK Field permissions",
>
> --
> Walter Garcia-Fontes
> Barcelona
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
> __________ Informacisn de NOD32, revisisn 2695 (20071130) __________
>
> Este mensaje ha sido analizado con  NOD32 antivirus system
> http://www.nod32.com
>
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>


More information about the support mailing list