@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’ );
@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.
Hello @imranmd, this solution no longer works and I get an error saying line 13 has a “Syntax error, unexpected token “>”.” (the line that says echo ‘<br>’;)
Can you help?
Hey @activadorr thanks for your message. How silly of me, I know about the curly quote issue and didn’t check this. I’ve changed all the quotes to straight quotes and works now. Thank you so much!
Follow up question:
Is there a way to change the code to display an excerpt from some other profile field type other than the “WordPress Fields” -> “Biography”? Specifically I am after displaying whatever is in the “Multi-Line text area” field type.
Thank you in advance to anyone who can help
Thanks @activadorr for the draft code suggestion. I am not a developer so forgive me for asking this, but how do I find the field identifier? I’ve been trying to find it and the only thing I can find is the field ID, which is a number such as “50”.