[Resolved] body_class filter for buddypress pages

I am using a plugin that uses the standard body_class filter to add body classes depending on your browser/device. However, it is not working on buddypress pages. Is buddypress not using this filter? Or could there be something else?

probably something else! have you checked through the plugin to see how it’s adding to the filter – references to the function aren’t necessary , and anyway that is the output function not a filter as such – BP does hook into the WP filter to add it’s own body classes ( as do I for my own purposes), look through the core files for it.

As you make no mention of the plugin or having checked what it’s doing I have to say this isn’t a BP issue why would the plugin be adding classes on BP page views, probably knows nothing about them.

Naturally, I posted this question on their forum. They answered that it is probably a buddypress problem, because they are using a wordpress filter. The plugin does add body classes (for browsers and devices) on all other pages (non buddypress pages).

Why should this not be working on buddypress pages? Yes. I have little knowledge of buddypress, that is why I am here.

That code test as working on a local BP install and in a custom BP theme so no it’s not a BP issue as such. All standard BP screens show the class added for the given browser. BP simply grabs the array $classes amd merges it’s own set of classes to that array before it’s rendered to browser, I ran the code from my functions.php so you may have some form of priority issue in when bp is cutting in and grabbing the array to merge to, but this is more to do with your theme I would guess and at what point that function is running. do try testing this function on a plain vanilla BP i.e swap to bp-default to test whether it works.

On a sidenote be wary of user agent sniffing it has never been considered a suitable way/ method of establish a user agent due to UA spoofing a regular and common practise that historically meant one couldn’t be sure of the query result being valid.

I tested the code on the bp-default theme (only wordpress and buddypress activated). It works on normal pages, but not on the buddypress pages (members/activity etc). Hence, it behaves the same as on the pagelines theme.

I tried different priority settings for the filter in the plugin, but without any results. Any other suggestions I could try?