Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] BP 1.5 unserialize profile field


  • shanebp
    Moderator

    @shanebp

    We need to show certain profile fields outside of the bp_has_profile loop.
    It seems, in 1.5, you can’t use xprofile_get_field_data() outside of the profile loop without doing your own unserializing.

    Inside a bp_profile_group_has_fields() loop, serialized fields are handled correctly.

    But on a profile page, outside that loop, they are not recognized as being serialized, therefore they are not unserialized.

    Example:

    
    $values = xprofile_get_field_data(97);
    echo $values;  //result: Array
    
    var_dump($values);
    //result: array(3) { [0]=> string(7) "Friends" [1]=> string(19) "Business Networking" [2]=> string(21) "Relationship / Dating" }
    
    // is_serialized($values)  // result: false
    
    //so you have to 'manually' unserialize them
    $all_values = array();
    foreach( (array)$values as $value ) {
    $all_values[] = $value;
    }
    $values_str = implode( ', ', $all_values );
    
    echo "<br>" . $values_str . "<br>";
    //result: Friends, Business Networking, Relationship / Dating
    
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] BP 1.5 unserialize profile field’ is closed to new replies.
Skip to toolbar