Birthday Privacy

    • 378 posts
    March 4, 2018 3:20 PM EST

    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:

    • Show Full date
    • Show month/day only
    • Show Age only
    • Show Nothing
    • 378 posts
    March 4, 2018 4:23 PM EST

    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.

  • gs
    • 857 posts
    March 4, 2018 6:05 PM EST

    What page and/or widget are you referring to (screenshot if possible)?

    • 378 posts
    March 4, 2018 10:37 PM EST

    I want it to show age (44) instead of full birthdate

     

  • gs
    • 857 posts
    March 4, 2018 10:57 PM EST

    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.

    • Moderator
    • 6923 posts
    March 5, 2018 6:35 AM EST

    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.

    • 378 posts
    March 5, 2018 10:19 AM EST

    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

    • Moderator
    • 6923 posts
    March 5, 2018 12:12 PM EST

    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. 

    • 378 posts
    March 5, 2018 12:27 PM EST

    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. 

    • Moderator
    • 6923 posts
    March 5, 2018 12:34 PM EST

    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.

     

    • 378 posts
    March 5, 2018 12:37 PM EST

    AWESOMESAUCE! Thanks for this!

    • Moderator
    • 6923 posts
    March 5, 2018 12:38 PM EST

    You're welcome laughing Hope it does what you want.

    • 378 posts
    March 5, 2018 12:54 PM EST

    Worked like a charm and so simple - thanks Madam!

    • Moderator
    • 6923 posts
    March 6, 2018 5:01 AM EST

    You're welcome