Display S2Member custom field in custom Buddypress profile

Howdy!

So I’ve been doing some research on this and can’t seem to get to a sufficient or good answer - so forgive me if this has already been discussed elsewhere.

I’m using S2member w/ BuddyPress to create public facing profiles that members of the site can edit for themselves. So far so good, however when trying to display some of the custom fields I’ve set up in S2member, I am running into issues with it simply not working.

I’ve added the following code into the profile-loop.php file from the Buddypress plugin:

<?php
 echo get_user_field ("occupation", $user->ID);
?>

That displays nothing.

I’ve added this as well:

<?php
foreach (get_users () as $user)
    {
        $user = /* Get full WP_User object instance. */ new WP_User ($user->ID);
        if /* If they're at least a "Subscriber", possibly a "Member". */ ($user->has_cap ("access_s2member_level0"))
            {
                echo get_user_field ("bio", $user->ID);
            }
    }
?>

Which displays my ‘bio’ field, but it does it twice (I’m guessing because I currently only have two users). Any help would be appreciated as I’ve been trying to knock this out and feel like I just need that last bit of push in the right direction.

Thanks!

I’m not sure whether these tips still work today, but you could try them: https://codex.buddypress.org/developer/user-submitted-guides/useful_func_s2_bp/

Thanks, Tim!

Did find that early on in my research and unfortunately had no such luck for getting those methods to work.

@leroyjames: If you need the value of each custom file for each member, you may do a MySQL query to read all of them from the “usermeta” table and then parse result to find what you need.