Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_activity_add strips html

  • @schweizersolutions

    Participant

    Hello,

    I have a problem with the bp_activity_add function. I try to save a activity with HTML code as content. But everytime I check the result on the stream, the HTML code is stripped.

    The code I use to write to the stream:

    
    $bp_activity_id = bp_activity_add(array (
      'user_id' => 99,
      'action' => '<a href="http://example.org/members/swiss/" title="Swiss">Swiss</a> anwered',
      'content' => '<p>This is a test</p><p>biut where are the paragraphs?</p>',
      'primary_link' => 'http://example.org/topic/test-it/',
      'item_id' => '9',
      'secondary_item_id' => '15996',
      'component' => 'groups',
      'type' => 'activity_update',
      'hide_sitewide' => true,
    ));
    

    And this is how the content looks like on the stream:

    <div class="activity-inner">
      <p>This is a testbiut where are the paragraphs?</p>
    </div>

    How can I fix it?

    Cheers
    Andreas

Viewing 2 replies - 1 through 2 (of 2 total)
  • @djpaul

    Keymaster

    The content property is run through KSES and the permitted HTML tags are set here: https://buddypress.trac.wordpress.org/browser/trunk/src/bp-activity/bp-activity-filters.php#L206

    You COULD unhook this function from the filter (see: lines 16-25, same file) but I would not recommend it, because other people will use this to inject malicious markup. Instead, consider using the bp_activity_filter_kses filter and whitelist a few extra HTML funtions that you need (i.e. just the paragraph tag).

    @schweizersolutions

    Participant

    Hey Paul,

    thats great, it works! Big thanks 🙂

    Cheers
    Andreas

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘bp_activity_add strips html’ is closed to new replies.
Skip to toolbar