Add xprofile data to Buddypress members loop on members page
Let’s add some xprofile data to the members loop on the Buddypress members page with a small code snippet.
To start of, we’ll need to construct the xprofile fields in the wordpress backend. Make your way to Users > Profile Fields and add a new field. If you already have an existing xprofile field you’d like to show on the members loop, you’re good to go.
The name for the xprofile field is the one we’ll be using to display the Buddypress user data in the following code snippet.
Copy paste the following code to your function.php or bp-custom.php.
* Add profilefield to members on members page
$field_content = bp_get_member_profile_data('field=YOUR FIELD NAME'); // enter your field name here
if ($field_content != false) echo '<div class="member-info">' . $field_content . '</div>';
add_action('bp_directory_members_actions', 'add_profilefield_to_members_loop', 90);