arildB
Background of the issue:
I am trying to filter Activities, Latest Replies, and Topics Widget for BuddyBoss. I have tested this solution: https://wpml.org/forums/topic/lang-not-filtered-in-activities-latest-replies-and-topics-widget-for-buddyboss/ but it doesn't seem to work anymore. Link to a page where the issue can be seen: hidden link
Symptoms:
I expected to see filtered posts for each language. Instead, I got mixed languages in activity feeds.
Questions:
Why is the language filter not working for Activities, Latest Replies, and Topics Widget in BuddyBoss?
Is there an updated solution for filtering languages in BuddyBoss widgets?
Osama Mersal
Hi,
Thanks for contacting WPML forums support. I'll be glad to help you today.
Please try the following code.
// Filter the activity feed by the language:
// 1. buffer the activity entry output...
add_action('bp_before_activity_entry', function () {
ob_start();
});
// 2. clean the output if the activity is the post activity and languages don't match,
// flush otherwise.
add_action('bp_after_activity_entry', function () {
$get_lang = apply_filters( 'wpml_current_language', NULL );
$language_code = get_activity_post_language_code();
if ( $language_code && $get_lang && $language_code !== $get_lang ) {
ob_end_clean();
} else {
ob_end_flush();
}
});
function get_activity_post_language_code() {
if ( ! bp_get_activity_secondary_item_id() ) {
return false;
}
$language_details = apply_filters( 'wpml_post_language_details', NULL, bp_get_activity_secondary_item_id() );
if ( ! $language_details ) {
return false;
}
return $language_details['language
Best regards,
Osama
arildB
Hi again Osama
Thanks for your quick reply. Unfortunately, it did break my site.
Cheers
Arild
Osama Mersal
Hi Arild,
Please log in to this sandbox site and install the BuddyBoss theme and plugins only. (hidden link )
After that, please try to replicate the issue. If it is replicable, please let me know how to reproduce it so I can consult our compatibility team.
Best regards,
Osama
arildB
Hi again
Working on it now
Cheers
Osama Mersal
Hi,
Thanks. Please take your time and let me know when you replicate the issue and how to reproduce it.
Best regards,
Osama
arildB
Hi Osama
Could you please review your snippet above? The last line seems to be wrong.
Cheers
Osama Mersal
Hi,
Sorry, it seems it's missing the last line. Here is the snippet:
add_action('bp_before_activity_entry', function () {
ob_start();
});
add_action('bp_after_activity_entry', function () {
$get_lang = apply_filters( 'wpml_current_language', NULL );
$language_code = get_activity_post_language_code();
if ( $language_code && $get_lang && $language_code !== $get_lang ) {
ob_end_clean();
} else {
ob_end_flush();
}
});
function get_activity_post_language_code() {
if ( ! bp_get_activity_secondary_item_id() ) {
return false;
}
$language_details = apply_filters( 'wpml_post_language_details', NULL, bp_get_activity_secondary_item_id() );
if ( ! $language_details ) {
return false;
}
return $language_details['language_code'];
}
Best regards,
Osama
arildB
Hi again
I'm sorry for not getting back to you sooner. I have now tested the script above thoroughly on the staging site and, unfortunately, found that it's not filtering post-PR language.
I have tested the following.
1. Installed BB Platform/Pro/theme/WPML-BP integration
2. Add the script above to the BB-child theme
3. Translated the activity feed + groups page
4. Created a NO group
5. Created a post in the NO group. Outcome: the NO post is showing in the EN feed
6. Created a post directly in the EN feed
7. Outcome: The EN post shows the NO activity feed.
Cheers
Arild
Osama Mersal
Hi Arild,
Thanks for your update. Please log in to this hidden link ">sandbox site and replicate the issue there.
If the issue is replicable, please let me know so I can consult our compatibility team and check if there is another workaround for this issue.
Thanks for your cooperation
Best regards,
Osama
arildB
Hi
The issue is replicated in the sandbox
Osama Mersal
Hi,
The sandbox site doesn't have the Buddyboss plugins, so please install them and replicate the issue on it. (hidden link )
Best regards,
Osama
arildB
Hi
You are looking in the wrong sandbox.
hidden link
Osama Mersal
Hi,
This is not the one I provided for you, so please share the login URL or access details for this sandbox.
Best regards,
Osama
arildB
Thats weird. It's the only sandbox link I got from you.
However, here is the autologin link; hidden link