I can get a profiles avatar and name by this code:
?php echo get_avatar(1); ?>
<?php
$user_id = 1;
$key = 'first_name';
$single = true;
$user_first = get_user_meta( $user_id, $key, $single );
echo '<span>' . '' . $user_first . '</span>';
?>
But then I also have BuddyPress installed and trying to get the new fields that I created there. I identified the id on one of the field to fields_2
This is what I have written that don’t work:
<?php
$user_id = 1;
$key = 'field_2';
$single = true;
$user_field = get_user_meta( $user_id, $key, $single );
echo '<span>' . '' . $user_field . '</span>';
?>
How can I get this field_2
from the extended BuddyPress field?
Check your database if it actually has “field_2”, your code should work fine. but you can also try using it inside the bp user loop and also replace get_user_meta with bp_get_user_meta. It works better with some buddy press plugins.