Skip to:
Content
Pages
Categories
Search
Top
Bottom

Shortcode returns string “Array”


  • FLASHVILLA
    Participant

    @flashvilla

    Good day

    Iv created an html table in my functions.php file, in the table data cell, I have a buddypress shortcode that should return results from a field with multiple checkboxs. The shortcode goes like this “bp_get_profile_field_data( ‘field=School Subjects’)”, what happens next is on display it returns string “Array” instead on the selected checkboxes. Please help on have I should allow my shortcode accept an array.

    Below is my table code:

    echo “<table border=’1′ align=’center’ width=’20’>”;
    echo “<tr>”;
    echo “<td style=’font-weight: bold;’>School Subjects</td>”;
    echo “<td style=’font-weight: bold;’>Extra Curricula Activities</td>”;
    echo “</tr>”;
    echo “<tr>”;
    echo “<td>

    “.do_shortcode(bp_get_profile_field_data( ‘field=School Subjects’)).”

    </td>”;
    echo “<td>”.bp_get_profile_field_data( ‘field=Number of Learners’).”</td>”;
    echo “</tr>”;
    echo “<tr>”;
    echo “<td>Teachers:</td>”;
    echo “<td>”.bp_get_profile_field_data( ‘field=Number of teachers in school’).”</td>”;
    echo “</tr>”;
    echo “</table>”;

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try wrapping the bp_get_profile_field_data() call in bp_unserialize_profile_field(), like this:
    bp_unserialize_profile_field( bp_get_profile_field_data( ‘field=School Subjects’) )

    I’m not sure what shortcodes are doing in there, but bp_unserialize_profile_field() will convert an array into a comma-separated list.


    FLASHVILLA
    Participant

    @flashvilla

    Hi thank you, your response has actually opened doors for me to find more solutions, my current shortcode looks like this “.implode(‘, ‘, bp_get_profile_field_data( ‘field=School Subjects’)).”, this allowed the data I needed to appear but the problem now is its comma delimited and I need the results to come out as a list.

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