Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Scyther CreditAttribution: Scyther commentedShould not this be a Views issue?
Maybe in Views, you don't have access to the $account variable?