Trying to replace PHP String to show different on output

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.

Read More

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.

Related posts

1 comment

  1. 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:

    if (bp_get_the_profile_field_name() == 'Date of Birth') {
        print 'Age';
    } else {
        print bp_get_the_profile_field_name();
    }
    

    Or through ternary operator (shorthand for if/else):

    <?php print bp_get_the_profile_field_name() ? 'Age' : bp_get_the_profile_field_name(); ?>
    

Comments are closed.