Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display portion of user bio in membership directory


  • stephunique
    Participant

    @stephunique

    Hello,

    I’d like to display a portion, say the first 60 characters or so of their bio (and a message if they have not filled it out) in their name card in the membership directory. At the moment it only shows their profile picture and their name underneath, and how long ago they were active.

    Thanks in advance to anyone that can help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @stephunique with the help of this code snippet, you can display the user bio on member directory.

    /**
    * User Bio on member directory.
    *
    * @return void
    */
    function display_user_bio_on_member_directory() {
    if ( ! bp_is_members_directory() ) {
    return;
    }
    global $members_template;
    $member_id = $members_template->member->id;
    $bio = get_user_meta($member_id, ‘description’, true);
    echo ‘<br>’;
    if( ! empty( $bio ) ){
    echo wp_trim_words( $bio, 60, ‘…’ );
    } else {
    echo esc_html( ‘Custom message for user bio is empty’ );
    }
    }
    add_action( ‘bp_directory_members_item_meta’, ‘display_user_bio_on_member_directory’ );


    stephunique
    Participant

    @stephunique

    @imranmd Thank you so much for this, it works perfectly for me on the child theme’s functions.php file of the latest version (4.6.8) of BuddyX theme.

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