Skip to:
Content
Pages
Categories
Search
Top
Bottom

Displaying XProfile Fields in Blog Directory


  • bennypowers
    Participant

    @bennypowers

    Hello
    I have a Multisite installation with BuddyPress. I’d like to display user’s extended profile fields in the site directory (blog loop)

    Based on the documentation, I’ve tried this:

    <?php
    
    add_action( 'bp_directory_blogs_item', 'display_user_xprofile' );
    function display_user_xprofile() {
        $args = array(
            'field'   => 'Phone', // Field name or ID.
            // 'field'   => 'Car', // Field name or ID.
            // 'field'   => 'Languages', // Field name or ID.
            );
        $phone_number = bp_get_profile_field_data( $args );
    
        if ($phone_number) {
            echo 'Phone Number: ' . $phone_number;
            // echo 'Car?: ' . $phone_number;
            // echo 'Languages: ' . $phone_number;
        }
    
    }

    Without success. Please advise how to display this info.

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

  • bennypowers
    Participant

    @bennypowers

    tried this, but it just prints the user id to page

    
    
    add_action( 'bp_directory_blogs_item', 'display_user_xprofile' );
    function display_user_xprofile() {
        $args = array(
            'user_id' => get_user_id_from_string( get_blog_option(bp_blog_id(), 'admin_email') ),
            'field'   => 'Phone', // Field name or ID.
            // 'field'   => 'Car', // Field name or ID.
            // 'field'   => 'Languages', // Field name or ID.
            );
        $phone_number = bp_get_profile_field_data( $args );
    
        if ($phone_number) {
            echo 'Phone Number: ' . $phone_number;
            // echo 'Car?: ' . $phone_number;
            // echo 'Languages: ' . $phone_number;
        }
    
    }

    bennypowers
    Participant

    @bennypowers

    Success! I needed to use bp_get_blog_id() instead of bp_blog_id()

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