Skip to:
Content
Pages
Categories
Search
Top
Bottom

XProfile Get Field Function


  • zaino
    Participant

    @zaino

    wp version 4.9.5
    bp version 2.9.4
    local install

    Hello all. I need some guidance tweaking this function. I have an XProfile field called Traffic, using a checkbox for values ‘Option 1’ and ‘Option 2’. The function below works great to display all checked values in my custom template.

    However what my ultimate goal is is to style the returned values differently. For example Option 1 would be a blue badge and Option 2 would be a red badge.

    How can I get the function to echo something different based on If Option 1, else Option 2? Thanks in advance.

    function x_traffic() { if ( bp_is_active( ‘xprofile’ ) )
    if ( $membertraffic = xprofile_get_field_data( ‘Traffic’, bp_get_member_user_id() ) ) :
    foreach($membertraffic as $membertraffic){
    echo ‘<span class=”bp-traffic badge badge-success mr-2″ style=””>’;
    echo $membertraffic;
    echo ‘</span>’;}
    endif;
    } add_filter ( ‘bp_directory_members_item’, ‘x_traffic’ );

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