Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a form that includes a multi-select box.

<form method="POST" action="">
  <select name="countries[]" size="5" multiple="true">
  <option value="bolivia">Bolivia</option>
  <option value="canada">Canada</option>
  <option value="ireland">Ireland</option>
  <option value="mexico">Mexico</option>
  <option value="united states">United States</option>
  <input type="submit" value="Submit" size="5"></p>

The code is displayed with the following PHP code:

<?php bp_member_profile_data( 'field=Countries' ); ?>

How do I separate the results into a bullet list?

share|improve this question
Make a var_dump() of the result of bp_get_member_profile_data( 'field=Countries' ), and add that to your question. –  toscho Mar 31 '13 at 14:14
add comment

1 Answer 1

From your comment below:

This code displays the members selections but only as a comma separated list: <?php bp_member_profile_data( 'field=Countries' ); ?>

// $countries_csl should contain something like 'hufflepuff, hogwarts, heaven, hell'
$contries_csl = bp_get_member_profile_data( 'field=Countries' );
// convert the comma seperated list (csl) into an array by using explode( [delimiter], [string] )
$countries = explode( ',', $countries_csl );

// check if the string to array conversion was successfull
if ( is_array( $countries ) && ! empty( $countries ) ) {
    // adjust the html to your needs (add some css classes or something else)
    echo '<ul>';

    // walk over the array and print out a li-item for each array element
    foreach ( $countries as $country ) {
        // to be sure that every country starts with an UpperCase letter, use ucfirst()
        printf( '<li>%s</li>', ucfirst( $country ) );

    // do not forget to close the list
    echo '</ul>';

You have a comma seperated list, you need a bullets list. Just convert the comma seperated list into an array and walk over it to generate a bullets list.

share|improve this answer
I apologize for the lack of detail. I'm not very proficient at PHP so not sure what information I need to provide. Anyway, I'm trying to display the results of a multi-select box from the BuddyPress profile registration page on to a single members page in a bullet list format. This code displays the members selections but only as a comma separated list: <?php bp_member_profile_data( 'field=Countries' ); ?> Let me know what else I need to provide. Thanks. –  user30766 Mar 31 '13 at 18:30
I have updated the answer. Please do not forget to accept the answer if it works, so other can see if it is the right soution or not. –  Ralf912 Apr 3 '13 at 10:26
@Ralf912 - I believe you need to use bp_get_member_profile_data(...) instead because he needs to get the list and then manipulate per your code. bp_member_profile_data(...) will echo the list. –  shanebp Apr 3 '13 at 17:23
@shanebp Ah thanks. I'm not so experienced with bbpress and take the code from his comment. –  Ralf912 Apr 3 '13 at 17:38
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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