[buddypress-trac] [BuddyPress Trac] #8573: Removing favorite forum topics does not work.
buddypress-trac
noreply at wordpress.org
Sun Sep 19 17:36:20 UTC 2021
#8573: Removing favorite forum topics does not work.
--------------------------+-----------------------------
Reporter: Dave Lozier | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Core | Version: 9.1.1
Severity: normal | Keywords:
--------------------------+-----------------------------
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.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8573>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list