WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

BuddyPress has a function (bp_member_profile_data) that pulls profile data into a members loop which looks like this:

bp_member_profile_data( 'field=Organization' );
bp_member_profile_data( 'field=Brief Biography' );  

* If you want to show specific profile fields here you can,
* but it'll add an extra query for each member in the loop
* (only one regardless of the number of fields you show):
* bp_member_profile_data( 'field=the field name' );   */

I'm wondering how to limit the echoed length of Brief Biography. I've looked at the Bavatosan example and substr but they're kind of beyond me at this point in terms of knowing where to modify them.

share|improve this question

closed as off-topic by birgire, ialocin, gmazzap, Johannes Pille, toscho Aug 16 '14 at 0:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

I think buddypress has a get* version of that function that returns the value instead of showing it on the screen.

So just cut the returned string after a certain amount of characters, like 50:

$profile_bio = bp_get_member_profile_data( 'field=Brief Biography' );

if(strlen($profile_bio) > 50))
  $profile_bio = substr($profile_bio, 0, 50).'...';

echo $profile_bio;

If there's no get function you can always use output buffering:

bp_member_profile_data( 'field=Brief Biography' );  
$profile_bio = ob_get_clean();

// rest of the code is the same
share|improve this answer
Perfect. Thanks very much! – Christopher Dec 11 '11 at 19:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.