Skip to:
Content
Pages
Categories
Search
Top
Bottom

Override Xprofile Group Name with Field Value


  • DevonHarper
    Participant

    @devonharper

    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?

Viewing 1 replies (of 1 total)

  • shanebp
    Moderator

    @shanebp

    >…not used on the profile group tabs when the user is editing their profile

    Try using the ‘xprofile_filter_profile_group_tabs’ filter hook in
    bp_profile_group_tabs() in
    \buddypress\bp-xprofile\bp-xprofile-template.php

Viewing 1 replies (of 1 total)
  • The topic ‘Override Xprofile Group Name with Field Value’ is closed to new replies.
Skip to toolbar