Back to GD bbPress Attachments Forum

Filtering the content of the attachment area

Published on: September 8, 2021 at 6:33 am · By: vortexmonkey
Author
Topic
#73789

Hello!

I’m trying to use the following to filter the content of the attachment area. It filters the content of the reply, but does not affect the attachment area.

add_filter( 'bbp_get_reply_content', 'myprefix_use_audio_short_tag' );
function myprefix_use_audio_short_tag( $content ) {
    $reg = "#<a .+? href=\"(.+?\.mp3)\".+?>(.+)</a>#";
    $content = preg_replace($reg, "<audio controls><source src='$1' type='audio/mpeg'>Your browser does not support the audio tag.</audio><br>$2<br>", $content);
    return $content;
}

If I change

add_filter( 'bbp_get_reply_content', 'myprefix_use_audio_short_tag' );

to have a priority of 1000, then it works. My question is, is there a better, more specific action I can filter so that the code works on the attachment area? Or is setting the priority to 1000 really the best option.

bbP version 2.6.6

Topic Information
General Question
7.4
5.7
4.2
Viewing 2 replies - 1 through 2 (of 2 total)
Author
Replies
  • #73790

    My plugin uses action priority 100 to add attachments, so you have to use 101 or more to run your code after. There is no other filter that can be used for that.

    Milan

    Dev4Press - Premium plugins for WordPress.

    1 user thanked author for this post.
  • #73794

    Thank you! That’s helpful.

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