Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Rename Field Label Depending On Member Type

@bcanr2d2

Participant

Whilst this works when the field is already set, I need the labels to change when the user selects the member type drop down BEFORE the field is saved.

My code is as below, but I am not sure how to get the information from the field before it is set, or if this is the correct function to change them on the fly.

function filter_bp_get_the_profile_field_name( $field_name ) { 
    // make filter magic happen here... 

	$user_id = bp_loggedin_user_id();
//	$bp_user_member_type = bp_get_member_type($user_id);
$bp_user_member_type = $_POST['field_6'];
//var_dump($bp_user_member_type);
//var_dump($user_id);
//die("filter_bp_get_the_profile_field_name");
	// field name (case sensitive)
	if ($bp_user_member_type == 'parent'  ) {
//	if( $field_name == 'Cost Per Hour' && 'edit' === bp_current_action() ){
switch($field_name) {

case 'Cost Per Hour':
//if( $field_name == 'Cost Per Hour' ){
$field_name = 'Maximum Amount To Pay For Sitting Per Hour';
break;

case 'Maximum Number Of Children Able To Sit':
$field_name = 'Number Of Children';
break;
case 'Age Ranges Of Children Able To Sit':
$field_name = 'Age Ranges of My Children';
}
	} else {
if ($bp_user_member_type == 'babysitterornanny'  ) {
switch ($field_name){
case 'Maximum Number Of Children Able To Sit':
$field_name = 'Maximum Number of Children I Am Able To Look After';
break;
case 'Age Ranges Of Children Able To Sit':
$field_name = 'Ages of Children I am Able to Sit';
break;
}
}
}
    return $field_name; 
}; 
         
// add the filter 
add_filter( 'bp_get_the_profile_field_name', 'filter_bp_get_the_profile_field_name', 10, 1 );
Skip to toolbar