Skip to:
Content

bbPress.org

Opened 5 years ago

Closed 4 weeks ago

#3454 closed defect (bug) (fixed)

Unsubscription action does not work when used with BuddyPress

Reported by: bradleyt Owned by: johnjamesjacoby
Priority: normal Milestone: 2.6.20
Component: Extend - BuddyPress Version:
Severity: normal 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 (5)

#1 @Robin W
4 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
4 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.

#3 @johnjamesjacoby
4 weeks ago

  • Milestone Awaiting Review → 2.6.20

#4 @johnjamesjacoby
4 weeks ago

In 7933:

BuddyPress: Restore member engagement actions.

Read BuddyPress member-page engagement actions from the request before passing them to the existing favorites and subscriptions handlers. BuddyPress fires bp_actions without arguments, so direct callback registration left the action empty and member-profile links reloaded without changing state.

In trunk, for 2.7.

Props bradleyt, robin-w, mike80222.
See #3454.

#5 @johnjamesjacoby
4 weeks ago

  • Owner set to johnjamesjacoby
  • Resolution → fixed
  • Status new → closed

In 7934:

BuddyPress: Restore member engagement actions.

Read BuddyPress member-page engagement actions from the request before passing them to the existing favorites and subscriptions handlers. BuddyPress fires bp_actions without arguments, so direct callback registration left the action empty and member-profile links reloaded without changing state.

In branches/2.6, for 2.6.20.

Props bradleyt, robin-w, mike80222.
Fixes #3454.

Note: See TracTickets for help on using tickets.