Skip to:
Content
Pages
Categories
Search
Top
Bottom

Preserving whitespace from bp profile fields


  • terraling
    Participant

    @terraling

    Sorry, I feel such a newb asking this, but it’s currently defeating me, so…

    I have an “About you” profile field which has the format Multi-Line Text Area.

    If the user writes a little about themselves and includes line-breaks, it looks as expected in the database table.

    Any variation of BuddyPress functions I use to retrieve the field for display in a template (e.g. $about = xprofile_get_field_data( 14, $user_id );) gives the same result when echoed.

    The raw source HTML has the linebreaks, but the whitespace including linebreaks is of course ignored when rendered on-screen.

    I know there are all kinds of text escaping functions and presumably I should be using one of them, but I don’t know where to start if anyone has any tips (or links to good reference material or tutorials).

    Thanks

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

  • Henry Wright
    Moderator

    @henrywright

    Hi @terraling

    Take a look at the first few lines in bp-xprofile/bp-xprofile-filters.php

    There’s lots of filters in place that act on the xprofile field value. Could be one of them?


    terraling
    Participant

    @terraling

    No, even if I bypass BP completely and construct a direct SQL query to return the field I have the same problem.

    It’s not really a BP thing, it’s very basic and why I feel a bit sheep-ish asking. I might be better off asking on SO…


    Henry Wright
    Moderator

    @henrywright

    No, even if I bypass BP completely and construct a direct SQL query to return the field I have the same problem.

    Humm, that rules out something like wp_filter_nohtml_kses acting on the returned value. SO is a good place to ask actually – hopefully someone over there can help out.


    terraling
    Participant

    @terraling

    God bless WordPress (and google).

    Don’t suppose many people have heard of it, but there is a function wpautop() which wraps text sections in <p> tags to preserve linebreaks.

    Thanks for your input @henrywright

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Preserving whitespace from bp profile fields’ is closed to new replies.
Skip to toolbar