I am using BuddyPress with Xprofile plugin.
The string in profile is Date of Birth, I want it to display Age on the profile page output instead.
This is the default code, it will display the profile field name and then the value for that field.
<dl<?php bp_field_css_class('dl-horizontal'); ?>>
<dt><?php bp_the_profile_field_name(); ?></dt>
<dd><?php bp_the_profile_field_value(); ?></dd>
</dl>
I want it to have an exception, if a string named “Date of Birth” appears in bp_the_profile_field_name(); , then it would display string “Age” instead, but display rest of fields the same as they are.
As stated in the comments, you should be able to see if the function
bp_get_the_profile_field_name()
returns the string ‘Date of Birth’, then do something appropriately.Example using if/else block:
Or through ternary operator (shorthand for if/else):