function birthdays_profile_alter in Birthdays 5
Same name and namespace in other branches
- 6 birthdays.module \birthdays_profile_alter()
Alter the way the birthday is shown. This is fired after every module has filled the profile.
File
- ./
birthdays.module, line 1063 - The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an e-mail on their birthday automatically, and the administrator can receive daily reminders of…
Code
function birthdays_profile_alter(&$account, &$fields) {
global $_birthdays_field;
// If the birthdays_field_id hasn't been set yet, do not continue
if (!isset($_birthdays_field)) {
return;
}
// If the field existed, and is amongst the profile fields to be shown, it is save to continue
if (array_key_exists($_birthdays_field->category, $fields) && array_key_exists($_birthdays_field->name, $fields[$_birthdays_field->category])) {
// Do you have access to see birthdays?
if (user_access('access birthdays')) {
// Show starsign (will be hidden when needed)
$starsign = '<span class="birthdays-starsign">' . birthdays_get_starsign_image($account->birthdays_starsign, variable_get('birthdays_show_starsign', BIRTHDAYS_STARSIGN_OFF)) . '</span> ';
// Show age (when allowed by user and administrator)
if (variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_NO || variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_USER && $account->birthdays_user_hide_year != BIRTHDAYS_HIDE_YEAR_USER_YES) {
$age = ' <span class="birthdays-age">(' . $account->age . ')</span>';
}
// Alter the profile field setup by profile.module. Show medium format in stead of short format
$fields[$_birthdays_field->category][$_birthdays_field->name]['value'] = $starsign . _birthdays_show_date($account->{$_birthdays_field->name}, $account, 'medium') . $age;
}
else {
// No access? Remove from profile to show
unset($fields[$_birthdays_field->category][$_birthdays_field->name]);
}
}
}