Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 - -
- - - - - - -

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 22 replies, has 2 voices.

Last updated by Osama Mersal 3 months, 2 weeks ago.

Assisted by: Osama Mersal.

Author Posts
July 14, 2024 at 12:02 pm #15950080

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?

July 14, 2024 at 12:44 pm #15950161

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

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

July 14, 2024 at 12:58 pm #15950169

arildB

Hi again Osama
Thanks for your quick reply. Unfortunately, it did break my site.

Cheers
Arild

July 14, 2024 at 1:08 pm #15950177

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

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

July 17, 2024 at 4:20 am #15963528

arildB

Hi again
Working on it now

Cheers

July 17, 2024 at 7:22 am #15964309

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks. Please take your time and let me know when you replicate the issue and how to reproduce it.

Best regards,
Osama

July 18, 2024 at 2:12 am #15969131

arildB

Hi Osama
Could you please review your snippet above? The last line seems to be wrong.

Cheers

July 18, 2024 at 6:31 am #15970083

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

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

July 23, 2024 at 5:20 am #15990309

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

July 23, 2024 at 8:19 am #15991160

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

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

July 23, 2024 at 8:30 am #15991235

arildB

Hi
The issue is replicated in the sandbox

July 23, 2024 at 8:58 am #15991524

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

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

July 23, 2024 at 9:00 am #15991526

arildB

Hi
You are looking in the wrong sandbox.
hidden link

July 23, 2024 at 9:01 am #15991533

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

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

July 23, 2024 at 9:06 am #15991566

arildB

Thats weird. It's the only sandbox link I got from you.
However, here is the autologin link; hidden link