Skip to:
Content

BuddyPress.org

Opened 4 weeks ago

Closed 4 weeks ago

#8573 closed defect (bug) (wontfix)

Removing favorite forum topics does not work.

Reported by: Dave Lozier Owned by:
Milestone: Priority: normal
Severity: normal Version: 9.1.1
Component: Core Keywords:
Cc: dave@…

Description

Fresh install of WordPress (5.8.1), bbPress (2.6.6) and BuddyPress (9.1.1) with default theme.

  • Create a forum
  • Create a topic
  • Click "Favorite" in topic
  • View your profile's Forums > Favorites page.
  • Click red X to remove favorite topic. (this step fails)

When in the topic bbPress uses an XMLHttpRequest to Favorite/Unfavorite. The previous used "GET" request linking does not work.

To fix this issue I am using some JavaScript to mimic what bbPress is doing with their templates/default/js/engagements.js file.

Here is an example fix that can be tested from your browser's console.

( function ( $ ) {

    var bbpEngagementJS = {
        bbp_ajaxurl:'',
        generic_ajax_error:'this is a generic error'
    };

    function bbp_ajax_call(action, object, type, nonce, update_selector) {
        var $data = {
            action: action,
            id: object,
            type: type,
            nonce: nonce
        };

        bbpEngagementJS.bbp_ajaxurl = $('#bbp-topic-'+$data.id).find('.bbp-topic-permalink').attr('href') + '?bbp-ajax=true';

        $.post(bbpEngagementJS.bbp_ajaxurl, $data, function (response) {
            if (response.success) {
                $('#bbp-topic-'+$data.id).remove();
                if ($('li.bbp-body').children().length === 0) {
                    /* no more favorites on the page */
                    location.reload();
                }
            } else {
                if (!response.content) {
                    response.content = bbpEngagementJS.generic_ajax_error;
                }
                window.alert(response.content);
            }
        });
    }

    $('#bbp-user-favorites').on('click', 'span a.favorite-toggle', function (e) {
        e.preventDefault();
        bbp_ajax_call(
            'favorite',
            $(this).data('bbp-object-id'),
            $(this).data('bbp-object-type'),
            $(this).data('bbp-nonce'),
            '#favorite-toggle'
        );
    });

})(jQuery);

I haven't checked, but I suspect there may be a similar issue with subscriptions.

Attachments (1)

Screenshot 2021-09-19 123430.png (60.0 KB) - added by Dave Lozier 4 weeks ago.
Favorite topics view.

Download all attachments as: .zip

Change History (2)

@Dave Lozier
4 weeks ago

Favorite topics view.

#1 @imath
4 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This is a bbPress issue, please report it there https://bbpress.trac.wordpress.org/

Note: See TracTickets for help on using tickets.