johngtur (@johngtur)

Forum Replies Created

Viewing 1 replies (of 1 total)
  • @johngtur

    Participant

    For anyone with the same problem, this appears to be a bug in BBPress. The script that is meant to fire when someone clicks the “subscribe” button (engagements.js) is only enqueued for the forum and topic post-types. When a forum or topic is embedded on any other post-type, the script is not enqueued, and the button doesn’t do anything.

    A quick fix is to add this to your functions.php file, to enqueue the script whenever a forum or topic is embedded via a bbp-single-topic / bbp-single-forum shortcode:

    add_filter( ‘do_shortcode_tag’,’subscription_button_fix’,10,3);
    function subscription_button_fix($output, $tag){

    $arr = array(‘bbp-single-topic’, ‘bbp-single-forum’);
    if(!in_array($tag, $arr)){
    return $output;
    }
    bbp_enqueue_script( ‘bbpress-engagements’, ‘js/engagements.js’, array( ‘jquery’ ), true );
    wp_localize_script( ‘bbpress-engagements’, ‘bbpEngagementJS’, array(
    ‘object_id’ => get_the_ID(),
    ‘bbp_ajaxurl’ => bbp_get_ajax_url(),
    ‘generic_ajax_error’ => esc_html__( ‘Something went wrong. Refresh your browser and try again.’, ‘bbpress’ ),
    ) );

    return $output;
    }

Viewing 1 replies (of 1 total)