I must be blind as I can not find it!
How do I control privacy around members birthdate display? By default it shows the actual date and I need it to be variable in what is shows:
Ok I figured out how to choose who can see the full birthdate but what I want to accomplish is to only show the age - IE 33 years old instead of the actual date.
What page and/or widget are you referring to (screenshot if possible)?
I want it to show age (44) instead of full birthdate
Since I don't know what page and widget you're referring to, I can only share that the SEAO Adv Members includes an option in their widget for Age that displays in format of '999 Years Old'. SES' offers a similar Plugin, but I don't know what options/settings are available. So if it's determined that SE doesn't provide this format/setting, at least you have alternative(s) to look at.
I don't see a setting to show Age in the profile fields (shown in the Info tab on a user profile). You could add it as a profile question though. That's the fastest way I can think of.
Adding it as a profile question does not allow me to alter the output to just show the age and would require the user to change their age every year manually
You're right, they would have to fix it each year manually. I'll bet this isn't a huge code change for one of your developers.
Odd thing is that SE almost got there - if you look in Members search when you have the proper criteria set in your profile questions they allow search via age range in years old.
Ok source edit. Only do this if you know what you are doing. Note it will be overwritten on upgrades. You should backup the original file before editing it. You should keep a copy of your changes someplace so that you can update without issues (by restoring original before upgrading and then reapply changes after upgrading).
This is not supported by SocialEngine. You assume all risks when editing source.
Find the file:
application/modules/Fields/View/Helper/FieldBirthdate.php
Make a copy of it as mentioned.
Around line 49 find the following:
age = (int)(- $birth_duration / 365 / 86400)
To show Birthday Date (age) like that, you would add the following line after the above line:
$label = $label.' ('.floor((time() - $value) / 31556926).')';
so it looks like this:
$age = (int)(- $birth_duration / 365 / 86400);
$label = $label.' ('.floor((time() - $value) / 31556926).')';
If you only want to show the age add this code instead:
$label = floor((time() - $value) / 31556926);
so it looks like this:
$age = (int)(- $birth_duration / 365 / 86400);
$label = floor((time() - $value) / 31556926);
Since the field says "Birthday" you may want to edit the profile question name to something such as Age or Birthday/Age or some such thing.
Clear your cache.
AWESOMESAUCE! Thanks for this!
You're welcome Hope it does what you want.
Worked like a charm and so simple - thanks Madam!
You're welcome