I am creating a classified ads site, and there will be an option for a printer friendly page for the ad. I have it setup so no phone numbers display on the node page, BUT I want the logged in creator of the node to only be able to print the printer friendly page WITH the phone number. Any other logged in user or anonymous user will be able to access the printer friendly page but SHOULD NOT be able to see the phone #.

I have been searching for 20 mn's in the support forums, and I cannot find something that exactly fits this requirement. Could anyone guide me? Thanks!

Comments

Sc0tt’s picture

If its a CCK field, you might be able to accomplish this using CCK's "Content Permissions" that may be enabled at admin/build/modules
Scott

tyler-durden’s picture

Thanks for the quick response. It is a cck field and I just enabled that module, and as I thought it is only broken down by roles.

I think I just need some kind of php if statement in my template, comparing the logged in userid to the node creator id. If they are the same, then I can show that field. PHP is not my strong area.

Sc0tt’s picture

PHP not my strong area either otherwise I would write some code that might do the trick. This is some code i recently created added to my node.tlp.php file to check if the logged in user has a particular role and do three different things based on it.

<?php global $user;
$subscriberRoles= array('Subscriber - 1Year','Subscriber - Day Pass');
$enlargePhoto= FALSE;
foreach($subscriberRoles as $role) {
	if( in_array($role, array_values($user->roles)) ) $enlargePhoto= TRUE; }
if($enlargePhoto) { ?>
	<a href="<?php print imagecache_create_url(1024, ${"field_inline_".$counter."_image"}[0]['filepath'], $bypass_browser_cache = FALSE); ?>">(+)Enlarge Photo</a><?php
} else if ($user->uid) { ?>
	<a href="/subscriptions/all-access-day-pass">All Access Day Pass ($1)</a> or <a href="/subscriptions/1-year-online-subscription">Subscription</a> required to (+)Enlage Photo<?php
} else { ?>
<a href="/user/register">Sign Up</a> or <a href="/user">Login</a> to (+)Enlage Photo<?php
} ?>

I'm off to bed so some other late night php Drupal guru will have to take over from here. Good luck.
Scott

tyler-durden’s picture

Hey, thanks! I think I can use this for a base to start on, but it will probably be after the weekend. Thanks for the start.