Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I strip useless markup: bp_the_profile_field_value()


  • ben_allison
    Member

    @ben_allison

    So I want to get bp_the_profile_field_value() but this function comes wrapped in a p tag, which is entirely unnecessary.

    A bunch of Buddypress functions come with their own markup. This makes for bloated front-end code.

    Is there a reliable way to return Buddypress functions without included tags?

Viewing 3 replies - 1 through 3 (of 3 total)
  • there is a reason tags are added as the field is a generic one that could be a textarea description that has been entered by user along with line breaks so adding the WP filter wpautop ensures line breaks are converted to semantic elements not nasty br tags.

    I don’t suggest this as an utterly reliabal approach or even correct one in WP terms but you could do:

    `echo strip_tags( bp_get_the_profile_field_value() )`

    Likely what you really need to look for is whether there is some filter you can hook into but that’s a lot of work for something that should be a matter requiring no effort really.

    Had a quick look through bp-xprofile-template.php to see where the tags originate from but they don’t appear in those functions above.

    but in bp-xprofile-filters.php we have:
    `add_filter( ‘bp_get_the_profile_field_value’, ‘wpautop’ );`

    So you need to reverse that filter for auto adding P tags from your functions file.


    ben_allison
    Member

    @ben_allison

    Thanks hnla!

    In the case of , it also wraps the value in an tag… this is not always desired. In some instances it is, in other it’s not.

    No it won’t always be desired, I agree, also though it’s not a huge issue and not semantically wrong, also it’s not necessarily bloat. If you wanted to be more select about things guess you could test for the field name and if a field you definitely didn’t want tags around then run the strip_tags. It’s a difficult issue to juggle really.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I strip useless markup: bp_the_profile_field_value()’ is closed to new replies.
Skip to toolbar