Opened 6 years ago
Closed 6 years ago
#8054 closed defect (bug) (fixed)
Filter bp_activity_custom_update params
Reported by: | Maniou | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 5.0.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Activity | Keywords: | |
Cc: |
Description
Hi,
On :
/bp-templates/bp-legacy/buddypress-functions.php
and
src/bp-templates/bp-nouveau/includes/activity/ajax.php
we have :
$activity_id = apply_filters( 'bp_activity_custom_update', false, $object, $item_id, $_POST['content'] );
but on
src/bp-activity/actions/post.php
we have :
/** * Filters activity object for BuddyPress core and plugin authors before posting activity update. * * @since 1.2.0 * * @param string $object Activity item being associated to. * @param string $item_id Component ID being posted to. * @param string $content Activity content being posted. */ $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
What is the good way to use this filter ?
Thanks you !
Change History (3)
#2
@
6 years ago
Hi @boonebgorges
Thanks a lot for the ping. Imho The filter in Nouveau or Legacy are more consistent than the one in https://buddypress.trac.wordpress.org/browser/trunk/src/bp-activity/actions/post.php#L85
I think we simply forgot to update the above file probably because this file is a fallback when JavaScript fails Ajax posting the activity.
So I'm in favor of using :
$activity_id = apply_filters( 'bp_activity_custom_update', 0, $object, $item_id, $_POST['content'] );
false
is fine too but as the filter should return the actvity_id of the posted custom activity I think it would be better :)
Good catch. The inconsistency was introduced in [9160], but I think that [9160] actually fixes a bug that was introduced when the original filter debuted in [2552]. The problem is that [9160] only fixed one instance of the filter. The one in bp-activity/actions/post.php should have the same signature. I'm going to ask @imath for a sanity check on that before I make the change. (For the record, this is a backward compatibility break, but the filter is unusable in its current state.)