Skip to:
Content

BuddyPress.org

#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)

#1 @boonebgorges
19 months ago

  • Milestone changed from Awaiting Review to 5.0.0

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.)

#2 @imath
19 months 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 :)

#3 @boonebgorges
19 months ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 12355:

Activity: Fix parameters for instance of bp_activity_custom_update filter.

This filter, introduced in [2552], is intended to allow developers to specify a
custom activity ID after posting to the "what's new" box. As originally
written, the filter didn't pass the right parameters to be properly used.
The instances of the filter that appear in bp-templates files were fixed in
[9160]; see #6021. The current changeset fixes the remaining instance.

Fixes #8054.

Note: See TracTickets for help on using tickets.