Skip to main content

Automatic age field on profile πŸ’‘

Hello team, it would be good to have an option that, when the date of birth is filled by the user, the profile automatically calculates and shows the age of the user. Many social networks and communities have that option and it would be great to have it here too.

WiLson Eberechi

Is this what you're talking about? If that's what you're talking about, it's already available in fluent community. See image

Fabio Pinna

WiLson Eberechi Hmm, not quite. This is just the DOB. I mean each member's age, which they can choose to show to others or keep private. This would be useful for events: before joining a space, someone could see the average age of its participants and decide whether to join.

Claudy Scoufy

I’d like to point out that the date does not support formats like "j F Y"(configured in the WordPress settingsβ€”I'm not sure if it relies on that) or "d/m/Y," for example; only "Y-m-d" is accepted.

Hi Fabio, Great idea! You can already do this with a small snippet. It works with the Date of Birth field you set up in Custom Profile Fields, and you don't need to create any new fields.

  • Shows the member'sΒ AgeΒ on their profile, calculated automatically from their Date of Birth. It updates by itself on their birthday.
  • Hides the full Date of Birth on the profile page.
  • Members still set and change their Date of Birth fromΒ Edit ProfileΒ as usual.

πŸ‘‰ Snippet + step-by-step guide with screenshots: https://gist.github.com/tawsifahmed/768d972a5704578ac55e30b0f1ff6f0d

Claudy Scoufy

Tawsif Ahmed Riyad :Β Regarding my message just before your reply, I would like the date of birth to be displayed in the standard European date format which is written in this order: Day / Month / Year?

Fabio Pinna

Tawsif Ahmed RiyadΒ Thank you πŸ™ I'll try this, even though I see that the date field is not in the european format, we use dd-mm-yyyy. If there was a workaround to fix it...

Fabio Pinna, Fabio Pinna, I will review the date format configuration. Meanwhile if you check my gist, the thing you want to achieve is possible via our provided fitler hooks.