Override Xprofile Group Name with Field Value
-
I am setting up a new site for families, and we would like to setup the site so that each user account represents a family. To do this we are thinking that we would like to add a new Xprofile Field Group to the user profile for each family member (Parent #1, Parent #2, Child #1, Child #2, etc.). However, when we are displaying the profile on the front end, we would like to replace the Profile Group Name with the value of a specific field from that group (i.e. ‘Name’).
I have added a filter to our functions.php file to accomplish this:
add_filter( 'bp_get_the_profile_group_name', 'child_update_profile_group_name' ); function child_update_profile_group_name( $name ) { global $group; //echo '<pre>' . print_r($group, true) . '</pre>'; if ( $group->fields[0]->name == 'Name' ) { $name = $group->fields[0]->data->value; } return $name; }
I will admit that this is sort of a hack. I have also noticed that the bp_get_the_profile_group_name filter is not used on the profile group tabs when the user is editing their profile. I am sure there are other areas where the group name is being displayed that are not filtered that I haven’t found yet.
Does anyone have any suggestions for a better filter or function to use to help us replace the profile group name when displayed on the front end?
- The topic ‘Override Xprofile Group Name with Field Value’ is closed to new replies.