Skip to:
Content

bbPress.org

Opened 3 years ago

Last modified 2 years ago

#3454 new defect (bug)

Unsubscription action does not work when used with BuddyPress

Reported by: bradleyt's profile bradleyt Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Extend - BuddyPress Keywords: needs-patch
Cc:

Description

On the susbcriptions page, the tables of subscribed topics and forums contain "x" links to unsubscribe. These appear not to work when Buddypress is installed. On click the subscription reloads with no action having been taken.

The class BBP_BuddyPress_Members contains this code:

// Move handler to 'bp_actions' - BuddyPress bypasses template_loader
remove_action( 'bbp_get_request', 'bbp_subscriptions_handler', 1 );
add_action(    'bp_actions',      'bbp_subscriptions_handler', 1 );

The method bbp_subscriptions_handler takes a single argument $action. However, this is not set in a buddypress context as the bp_actions action is called as do_action( 'bp_actions' ); without arguments.

An easy fix would be to read the $_GET directly in bbp_subscriptions_handler.


Change History (2)

#1 @Robin W
2 years ago

see https://buddydev.com/support/forums/topic/x-icon-to-delete-subscriptions/

Fix BbPress 2.6 bug not allowing handling of subscription actions from profile.
add_action( 'bp_actions', function () {

if ( empty( $_GETaction? )
! is_string( $_GETaction? ) ! function_exists( 'bbp_subscriptions_handler' ) ) {

return;

}

Sanitize the GET action
$action = sanitize_key( $_GETaction? );

Bail if action was totally invalid
if ( empty( $action ) ) {

return;

}

bbp_subscriptions_handler( $action );

}, 1 );

#2 @mike80222
2 years ago

I did a rather quick test of this code on my test site:

<?php
    // BuddyPress -> Profile -> Forums -> Subscriptions
    // [x] does not work to unsubscribe. Bug in bbPress code.
    // bbpress.trac.wordpress.org/ticket/3454
    // Fix originally suggested by Brajesh at BuddyDev.com
    // buddydev.com/support/forums/topic/x-icon-to-delete-subscriptions/

    add_action( 'bp_actions', function () {

    if ( empty( $_GET['action'] )
        || ! is_string( $_GET['action'] )
        || ! function_exists( 'bbp_subscriptions_handler' ) ) {
            return;
    }

    // Sanitize the GET action
    $action = sanitize_key( $_GET['action'] );

    // Bail if action was totally invalid
    if ( empty( $action ) ) {
        return;
    }

    bbp_subscriptions_handler( $action );
}, 1 );

and it appeared to work. I am neither a bbPress nor a BuddyPress developer and it would be good if someone with more experience could vet this.

Note: See TracTickets for help on using tickets.