Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress checkbox field display in profile


  • auch07
    Participant

    @auch07

    Hello,

    I am wondering if there is a way to format how a checkbox profile field displays in the profile.

    Ex:

    What are your favorite sports?
    Checkbox options of Hockey, Golf, Soccer, Football and Basketball.

    User selects Hockey, Golf and Football.

    Code I have right now is as follows:

    <?php
    $myfield = xprofile_get_field_data( 'Favorite Sports', $user_id_from_email, $multi_format = 'comma' );
    if ( empty ( $myfield) ):
    ?>
    <?php else: ?>
    <p><b>Favorite Sports:</b> <?php echo $myfield; ?></p>
    <?php endif; ?>


    Way it displays is:

    Favorite Sports: Hockey, Golf, Football

    Is it possible to have it display the results vertically?

    Hockey
    Golf
    Football

    Is this at all possible or am I dreaming lol?

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

  • shanebp
    Moderator

    @shanebp

    You could explode to an array and then loop thru it.

    But the default is to return an array, so just remove this
    $multi_format = 'comma'

    Then use a foreach loop to generate some markup that uses br or li tags.


    auch07
    Participant

    @auch07

    Thanks for the reply Shane. My apologies for the delay in responding myself but I just got back on working on this issue this weekend here.

    One field I am working on right now involves displaying either Services Required or Services Provided as you can see in the code below. Depending on the type of user you are will determine which field you have filled in thus which field will display on the user profile. Unfortunately my PHP is pretty weak thus the foreach loop you mentioned has me scratching my head. The code below does what I want with the exception of it displaying horizontally instead of vertically. I am hoping you would be able to give me some detailed direction in what way to go for the PHP challenged guy that I am lol.

    <?php
    $bpProfileField = xprofile_get_field_data( 'Services Required', $user_id_from_email, $multi_format = 'comma' );
    if ( empty ( $bpProfileField) ):
    ?>
    <div class="profile_fields"><b>Services Provided:</b> <span><?php bp_profile_field_data( 'field=Services Provided' );?></span></div>
    <?php else: ?>
    <p><b>Services Required:</b> <?php echo $bpProfileField; ?></p>
    <?php endif; ?>

    auch07
    Participant

    @auch07

    Sorry code I posted back was outdated.

    <?php
    $bpProfileField = xprofile_get_field_data( 'Services Required', $user_id_from_email, $multi_format = 'comma' );
    if ( empty ( $bpProfileField) ):
    ?>
    <div class="profile_fields"><b>Services Provided:</b> <span><?php bp_member_profile_data( 'field=Services Provided' , $user_id_from_email ) ?></span></div>
    <?php else: ?>
    <p><b>Services Required:</b> <?php echo $bpProfileField; ?></p>
    <?php endif; ?>
    <br>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Buddypress checkbox field display in profile’ is closed to new replies.
Skip to toolbar