Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to display a custom field?

@mcuk

Participant

Hi David,

Copying the code method does work. (Renaming the function, the variables/fields within and the add_action bits).

Just tried this out too and it appears to work fine, though not tested thoroughly so you’d need to double check:

function bptest_show_a_field () {
	$user_id = bp_loggedin_user_id();
	$field_one = xprofile_get_field_data( 'Field One', bp_loggedin_user_id(), $multi_format = 'comma' );
	$field_two = xprofile_get_field_data( 'Field Two', bp_loggedin_user_id(), $multi_format = 'comma' );
 
	if ( ! $field_one && ! $field_two ) { 
	   return; 
	}   
	else {
	   echo $field_one ; 
	   echo $field_two ; 
	}
}

add_action ( 'user_a_field', 'bptest_show_a_field' );

Then put do_action ( 'user_a_field' ); in your desired location.

Skip to toolbar