I'm using i.e. this php-snippet (in the author-pane.tpl.php) which display a user's age.

<?php
$year_diff = date("Y") - ($account->profile_birthday['year']);
$month_diff = date("m") - ($account->profile_birthday['month']);
$day_diff = date("d") - ($account->profile_birthday['day']);
if ($month_diff < 0)
  $year_diff--;
elseif ($month_diff == 0 && $day_diff < 0)
  $year_diff--;
print 'Age: ' . $year_diff;
?>

I've tried to create a Views block (besides the Authorpane block) where I want to display the user's age, using Views Views Custom Field (or Views PHP field) but the code above does not work in Views, so I wonder if it would be possible to rewrite the code to make it work..?

Comments

Scyther’s picture

Should not this be a Views issue?

Maybe in Views, you don't have access to the $account variable?