Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to display a custom field?

@stilld

Participant

Jigesh,

Thanks for the help! This is how it looks right now:

Screenshot order.php

As you can see to the right of the profile image their are some data showing from the custom fields. @mcUK and @shanebp helped me out achieving this. BUT, this is not the correct data it should be showing for this user… It shows data that the logged in user filled in.

I logged in as the user that filled in the correct data, and then it’s showing the right data for the user. But this is because I’m logged in as that user…

Screen

NOTE: I’m transferring this data across two plugins: buddypress and learnpress. Just so you know!

This is the php in bp-custom:

<?php

function bptest_show_a_field () {
	$user_id = bp_loggedin_user_id();
	$firstname = xprofile_get_field_data( 'First Name', bp_loggedin_user_id(), $multi_format = 'comma' );
	$lastname = xprofile_get_field_data( 'Last Name', bp_loggedin_user_id(), $multi_format = 'comma' );
	$birth = xprofile_get_field_data( 'Date of birth', bp_loggedin_user_id(), $multi_format = 'comma' );
	$education = xprofile_get_field_data( 'Highest Education Grade', bp_loggedin_user_id(), $multi_format = 'comma' );
	$profession = xprofile_get_field_data( 'Profession', bp_loggedin_user_id(), $multi_format = 'comma' );
 
	if ( ! $firstname && ! $lastname && ! $birth && ! $education && ! $profession ) { 
	   return; 
	}   
	else {
	    echo 'Voornaam: ' . $firstname . '<br />' ; 
	    echo 'Achternaam: ' . $lastname . '<br />' ; 
	    echo 'Geboortedatum: ' . $birth . '<br />' ; 
	    echo 'Hoogste graad: ' . $education . '<br />' ; 
	    echo 'Beroep: ' . $profession . '<br />' ; 
        
	}
}

add_action ( 'user_a_field', 'bptest_show_a_field' );
?>
 
Skip to toolbar