Skip to:

Opened 5 years ago

Last modified 5 years ago

#7918 new defect (bug)

Filter for bp_nouveau_get_filter_options to change dropdown options

Reported by: wbcomdesigns's profile wbcomdesigns Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version: 3.0.0
Component: Templates Keywords:


With the legacy support, we were able to use bp_get_activity_show_filters to change activity filter options.

Inside nouveau, we are using bp_nouveau_filter_options inside template files which do not allow to change drop down values.

Lots of people need to remove some default type activities removed from activities like member registered, friendship accepted.

We had created for it which is working fine with Legacy, but have issues with nouveau. To fix the problem, we need to filter bp_nouveau_get_filter_options output as follows

\buddypress\bp-templates\bp-nouveau\includes\template-tags.php need modified to add filter option for it.

function bp_nouveau_get_filter_options() {
		$output = '';

		if ( 'notifications' === bp_current_component() ) {
			$output = bp_nouveau_get_notifications_filters();

		} else {
			$filters = bp_nouveau_get_component_filters();

			foreach ( $filters as $key => $value ) {
				$output .= sprintf( '<option value="%1$s">%2$s</option>%3$s',
					esc_attr( $key ),
					esc_html( $value ),

			$output = apply_filters( 'bp_nouveau_filter_dropdown', $output, $filters );

		return $output;

Attachments (2)

7918.patch (777 bytes) - added by wbcomdesigns 5 years ago.
my suggestion to fix it
7918.01.patch (881 bytes) - added by r-a-y 5 years ago.

Download all attachments as: .zip

Change History (12)

5 years ago

my suggestion to fix it

5 years ago

#1 @r-a-y
5 years ago

  • Component changed from Core to Templates
  • Milestone changed from Awaiting Review to 3.2.0
  • Version set to 3.0.0

I think the problem is how Nouveau attempts to fetch the activity filter options.

Can you try the 01.patch to see if your plugin will work with Nouveau, @wbcomdesigns ?

#2 @wbcomdesigns
5 years ago

@r-a-y we have also tried to change the priorities in the first attempt, but it will not work.

In the legacy template, bp_activity_show_filters() call directly on the page and this function has a hook for filter result so we can easily filter HTML and add selected attribute for default filter
But in the nouveau template, bp_nouveau_filter_options() call for display filter dropdown, and we don't have a filter for this function result.

#3 @r-a-y
5 years ago

  • Keywords reporter-feedback 2nd-opinion added

@wbcomdesigns - I took a look at your bp-activity-filter plugin and how Nouveau works and I think you can fix this problem if you hook your plugin to 'bp_get_activity_show_filters_options' instead of 'bp_get_activity_show_filters' in your WbCom_BP_Activity_Filter_Public_Setting class. Can you try that?

'bp_get_activity_show_filters' outputs the entire <option> HTML, whereas 'bp_get_activity_show_filters_options' filters the dropdown options as an array. So the latter is easier to work with and you won't have to deal with HTML.

Last edited 5 years ago by r-a-y (previous) (diff)

#4 @wbcomdesigns
5 years ago

@r-a-y we can use the bp_get_activity_show_filters_options to hide option values but here we have to mark default selected that why we are sticking with html filter option.
Like by default we have everyone as selected and lots of people want to display all post updates by default.

Inside the legacy, we have filter option for both as an array and HTML but inside the nouveau template, we have only filter as an array.

Hopefully, it makes sense now.

#5 @r-a-y
5 years ago

  • Keywords dev-feedback added; reporter-feedback 2nd-opinion removed

Yeah, it seems you are right, @wbcomdesigns.

It's unfortunate to create another filter for this, but it looks like it is the only way.

#6 @imath
5 years ago

Hi @r-a-y & @wbcomdesigns

Thanks for the report and the work on this ticket. I think 7918.01.patch is a good first step. I also think, adding a new filter to edit the default selected value is a possible way, but as the selected value is set using JavaScript (see buddypress.js or buddypress-nouveau.js), I'd probably do it using JavaScript to avoid parsing the output.

In legacy, this can be done by setting the $.cookie( 'bp-activity-filter' ) cookie with the default value if it's not set yet and in Nouveau by setting the bp-activity session storage filter property with the default value. Here's an example of how you can achieve it :

I would recommend to work on a Core JavaScript file to store some default values just like this one in a future release so that it's easier for plugin developers to get/set informations about scope, filter, current action, current component etc.. Just like the buddypress() or global $bp does.

#7 @DJPaul
5 years ago

@imath Do you mean this patch is appropriate, so we can get this into v3.2.0, or do you think it needs more work (so v4.0)?

#8 @imath
5 years ago

@DJPaul I think the patch can be committed for 3.2.0 as soon as we edit the @version tag if it’s not set to 3.2.0

But I also think we should probably improve it in 4.0.0 using a specific JavaScript file to set this kind of globals.

#9 @DJPaul
5 years ago

  • Keywords dev-feedback removed
  • Milestone changed from 3.2.0 to 4.0

Looking more closely, current patch doesn't actually address issue.

#10 @DJPaul
5 years ago

  • Milestone changed from 4.0 to Awaiting Contributions
Note: See TracTickets for help on using tickets.