Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to display a custom field?

@shanebp

Moderator

You don’t explain the context of order.php.

bp_get_member_profile_data is meant for use in the context of members loop, etc.

You can use it outside that context, but you need to pass in the user id.

$args = array(
     'field'   => 'Opleiding',
     'user_id' => bp_loggedin_user_id()
);
$opleiding_field = bp_get_profile_field_data($args);

You can also use this approach:
xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' )
For example:

$user_id = bp_loggedin_user_id();
$opleiding_field = xprofile_get_field_data( 'Opleiding', bp_loggedin_user_id(), $multi_format = 'comma' );

Yes, it can be confusing.
You should always find & review the function you are trying to use within the codebase.
Doing so will reveal what the function expects to receive.

Skip to toolbar