Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show list of xProfile Field values?


  • bdd
    Participant

    @bws-online

    I would like to ask members for Blog Name and Blog Address (URL) in their profiles, and then if they fill in those fields, I’d like to display that info on a Member Blogs list on a separate page.

    Is there a way to do this?

    Wishlist:
    1. Ideally, I’d like to require both Blog Name and Blog Address if one or the other is filled in.
    2. I’d like to display the username (linked to the member’s profile) along with the linked blog name.

    Thanks.

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

  • Venutius
    Moderator

    @venutius

    You can add shortcodes to display the members profile fields and links to profile using BP Profile Shortcodes Extra. I don’t think you can set a condition that if one profile field is filled in then so should the other one by default but you could write some code to carry out that check an reject the change if the appropriate field is not filled in.


    bdd
    Participant

    @bws-online

    Thank you!

    So if I’m on a new page, and I want to list a particular field for ALL current members who’ve filled in that field, how would I do that? (I’m looking through the shortcodes and not seeing it yet.)

    And then how would I show more than one field for each member?


    Venutius
    Moderator

    @venutius

    Actually it might not work. The issue is that you have to be able to pass the user_id to the shortcode. On BuddyPress pages you can use the BP displayed user id, on posts you can use the post author user_id.

    alternaive typical use would be to manually code the user id:

    [bpps_profile_field option="Two" field="your-field" user_id="1"]


    bdd
    Participant

    @bws-online

    Thanks. That doesn’t sound like the solution I’m looking for, though. I want a single page to show all current members, not a page for each individual user when they’re logged in?

    And manually coding wouldn’t work, either.

    It feels like there should be some way to loop through all of this on a single page to display what I want, I’m just not seeing it yet since this is so new to me.


    Venutius
    Moderator

    @venutius

    I’ve created a group member list shortcode in the same plugin that allows extra profile fields to be displayed as part of a group member list, don’t suppose all the members you want to display belong to the same group?


    bdd
    Participant

    @bws-online

    No. Not using groups yet.


    Venutius
    Moderator

    @venutius

    One option would be to setup a members list and filter the members based on if they have certain profile fields set then display the extra profile fields in the loop.


    bdd
    Participant

    @bws-online

    YES! That’s what I’ve been fiddling with, but I’m struggling to get it to work. As an example, one roadblock I found with BP Profile Search and Custom Directories, and it’s not set to work with Nouveau templates (which is what my site’s using).

    Is there a tutorial you know of that would help me set up a template that would do this, and then I could indicate that a particular page should use that template?


    Venutius
    Moderator

    @venutius

    Sorry I don’t.

    The code to get the xprofile field data for a member is as follows:

    $field_data = xprofile_get_field( $field_id, $user_id, true );
    $field_value = $value->data->value;

    One thing you could do as a first step is to add these fields to the standard members loop:

    add_action( 'bp_directory_members_item', 'bpex_add_profile_field_data' );
    
    function bpex_add_profile_field_data() {
        $field_data = xprofile_get_field( $field_id, bp_member_user_id(), true );
        $field_value = $value->data->value;
        
        echo '<span>' . $field_value . '</span>';
    }

    You’d need to supply the $field_id for this to work.

    That would obviously add this data to all the members directory view which may not be what you want but it’s a start.


    bdd
    Participant

    @bws-online

    Thanks again. I’ll try that.

    I’ve been making some progress and getting closer. Created a new template with a copy of the member directory code, then started manipulating that.

    Tried using what’s in the “Filtering by Xprofile fields” section here to guide me:
    https://codex.buddypress.org/developer/loops-reference/the-members-loop/

    Right now I have a few errors, but I also see a link to just the one member that has a blog field filled in. (Long way to go, but feels like I’m getting to the right track.)


    bdd
    Participant

    @bws-online

    Update — looks like the errors I was seeing were from some sort of stray invisible characters at the end of the PHP file. Moving on. 🙂 Hopeful. 🙂

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