Check value of profile field – displaying images instead

Discussion in 'WordPress' started by Divvy, Sep 19, 2017.

  1. #1
    Hello guys,

    Is it possible to check if a custom profile field (checkbox) value is x, y, and z.
    My purpose for this is to display a corresponding image for each possible choice, in user profile and under user avatar in bbpress.

    Example:

    Male: male symbol image
    Female: female symbol image
    Couple: male+female symbols image

    I have found this code:

    $some_field = bp_get_member_profile_data( 'field=Name of Field' );
    if( !empty( $some_field ) ) {
         if( $some_field == 'x') 
            echo 'x'; 
         elseif( $some_field == 'y') 
            echo 'y'; 
         else
            echo 'z'; 
    }
    PHP:
    But for some reason, is not working…
    and it seems that is for profile page only…
    For outside of profile pages, I need to use this code: http://hookr.io/functions/xprofile_get_field_data/

    Unfortunately my PHP knowledge is very low.

    Is it possible to have the right function code for my case, please? :)

    Thanks!!
     
    Divvy, Sep 19, 2017 IP