Just wanting to note that I appear to have resolved this by updating the function in the section adunit_topic_betweenposts to:
function bbp_sau_filter_betweenposts($content, $reply_id) {
global $bbp_sau_opt_vals, $bbp_sau_runonce;
$location = 'adunit_topic_betweenposts';
if ($bbp_sau_runonce == 1) {
return $content;
} else {
$bbp_sau_runonce = 1;
}
// Check if we're generating content for the WYSIWYG editor
if (defined('DOING_AJAX') && DOING_AJAX) {
return $content; // We are in the editor, don't modify the content.
}
// Check if the content contains the specific class 'bbp-form'
if (strpos($content, 'class="bbp-form"') !== false) {
// If the class is found, return the original content without modification
return $content;
}
if (sau_is_hidden($location)) {
return $content;
}
// Retrieve the ad code based on your settings
$ad = isset($bbp_sau_opt_vals['positions'][$location]['ad_code']) ? $bbp_sau_opt_vals['positions'][$location]['ad_code'] : '';
// If ad code is available, proceed with inserting the ad content
if (!empty($ad)) {
// MANIPULATE POST OUTPUT
$content = $content . '</div></div> <!-- .bbp-reply -->
<div class="bbp-reply-header">
<div class="bbp-admin-links">
</div><!-- .bbp-meta -->
</div><!-- .bbp-reply-header -->
<div style="text-align:center;padding-top:20px">
<!-- .bbp-adunit -->' . stripslashes($ad) . '<!-- .bbp-adunit-end -->
</div>
<div><div>';
}
return $content;
}
// Add the filter
add_filter('bbp_get_reply_content', 'bbp_sau_filter_betweenposts', 100, 2);