Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display some user data on a single page


  • cbeckley
    Participant

    @cbeckley

    I am attempting to display some user data on a single page so members of a group can see all of the members within that group’s info without going into each profile. I have successfully displayed 2 custom fields, but cannot display the user’s email address.

    It is a private site, so I cannot link to it. Hopefully this is something minor that I am just missing.

    I have found so many scattered suggestions for this type of thing, but nothing has worked.
    I have tried all of these types with various field names (email, Email, Email address, Account email, etc.) and nothing displays the email address.

    <?php echo bp_member_profile_data(‘field=Email’); ?>

    <?php echo bp_member_profile_data(‘field=Account email’); ?>

    <?php echo xprofile_get_field_data( ‘field=Account email’ ); ?>

    <?php echo get_post_meta(get_the_id(), ‘user_email’, true); ?>

    <?php echo xprofile_get_field_data( ‘user_email’, get_the_author_id()) ?>

    I am updating a copied version in my theme of members.php from /buddypress/members/

    Any ideas would be appreciated. Thanks!

    BP v2.9.2
    WP v4.9.1

Viewing 3 replies - 1 through 3 (of 3 total)

  • Henry Wright
    Moderator

    @henrywright

    If you have the user’s ID then you can pass it to the get_userdata() WordPress function like this:

    $user_id = 1;
    $user = get_userdata( $user_id );

    Then you can use the $user object like this:

    echo sanitize_email( $user->user_email );

    Note, how you get the user’s ID will depend on the context. See:

    Playing with the user’s ID in different contexts


    cbeckley
    Participant

    @cbeckley

    Thanks for the response, but based on your answer, I don’t think that I explained my issue very well (or I just don’t understand the answer). If I were to use each individual user’s ID, then every time there is a new member, I have to write a new line? That doesn’t make sense to me.

    I am simply trying to alter the member list within a group to show contact details of each member on that single page, rather than forcing a user to look into each profile for that information.

    Maybe I am just missing some fundamental understanding and if so, then I apologize. Thanks for any more advice you may have.


    Henry Wright
    Moderator

    @henrywright

    If I were to use each individual user’s ID, then every time there is a new member, I have to write a new line?

    You won’t have to write a new line when a member is added. My code should be used within a loop so you’ll perform the action on every member in the collection. Adding to or removing from the collection isn’t a problem. The collection in your case is the group’s members.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar