Show CCK field only when accessing specific url (permissions)

100 Views Asked by At

My situation is that I want to restrict users access to a certain CCK field. After a user has made a purchase (Ubercart) they will be emailed a special link where they will have access to the field. This link will expire after a certain amount of time but they need to have access to that one specific field while the link is active.

basically what is happening is that when accessing the node using it's standard path (node/14) they will not have access to the field. If they access it through another path (available/for/limited/time/u9xYs4) they do have access to the field.

I am stumped how to accomplish this.

Edit 1:
I hack that I came up with that works is the following.

global $user;
$user1 = user_load(array('uid'=>1));
$prevUser = $user;
$user = $user1;

$view = views_get_view('greeting_listen');
$rendered = $view->preview('default', array($nid));

$user = $prevUser;

I know that is ugly but it works. I'm also concerned that there may be some major security issues. Does anyone have any thoughts on this for me?

1

There are 1 best solutions below

1
On

Depends on how you're creating and expiring the link, but...

I would include a CCK field for expiration time, remove the secret field from the node template, and create a View that displays the secret field and is filtered or otherwise altered based on expiration time.