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.

Tagged: 

This topic contains 18 replies, has 2 voices.

Last updated by Andrey 1 year, 7 months ago.

Assisted by: Andrey.

Author Posts
June 13, 2023 at 3:59 pm #13819193

mykolaK-6

I am trying to: make the activity feed filter posts by language.

Link to a page where the issue can be seen:
* Russian - hidden link
* Ukrainian - hidden link

I expected to see: *only* posts written in Ukrainian in the activity feed when Ukrainian is selected. And the same for Russian.

Instead, I got: posts in both languages, no matter what language is selected.

Note, filtering works well in the news feed, but for some reason, it doesn't work for the activity feed.

Please see the video provided hidden link

June 15, 2023 at 8:37 am #13830405

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for contacting WPML support.

How did you create your activity feed? If you temporarily disable all 3rd party plugins except WPML, do you still see the issue?

Could you please update your WPML plugin to the latest version 4.6.3, and add-ons to benefit from the latest bug fixes and improvements? This may not necessarily resolve your problem, however, in order to troubleshoot the issue best, we need to work on the latest code available.

You can check the latest released versions under "My Account -> Downloads" on this site. Instructions to update can be found here: http://wpml.org/faq/install-wpml/

Please remember to back up your database first before you proceed! You can use a plugin for this if you like (example: http://wordpress.org/plugins/duplicator/)

Let me know if the issue persists after an update has been done.

June 20, 2023 at 8:42 am #13857131

mykolaK-6

Hello Andrey!

Sorry for the delay, we had issues upgrading WPML on our staging.

The activity feed is created by the BoddyBoss theme. On staging, where we do most of the testing, everything is disabled except BuddyBoss and WPML. BuddyBoss cannot be disabled for this use case, as we need the activity feed.

After upgrading WPML and disabling everything, we still have this issue.

I can provide you with the testing credentials to our staging so you can play with it yourself.

Best regards

June 20, 2023 at 4:14 pm #13861853

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for your feedback!

We just released new WPML plugins. Could you please update your WPML plugin to the latest version 4.6.4?

If the issue persists after an update has been done, I need to request temporary access (wp-admin and FTP) to your site – preferably to a test site where the problem has been replicated, if possible – in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private, meaning only you and I can see and access it.

June 22, 2023 at 8:36 pm #13880857

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for providing information. Your hosting or the key doesn't allow me to update WPML plugins automatically.

Please reconnect the staging site with the newly generated key to further update the plugins. You would also have to update WP itself and the current theme to the latest versions.

https://wpml.org/faq/install-wpml/#register

It is also possible to update WPML plugins manually. You can download them from your account:
https://wpml.org/account/downloads

Let me know if the issue persists after an update has been done.

June 23, 2023 at 8:24 am #13882673

mykolaK-6

Andrey, I've upgraded WP and WPML and the issue still persists.

June 26, 2023 at 8:09 pm #13898061

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for being so patient.

I checked and learned about the issue you have faced.

The issue appeared to have already been considered and escalated to the compatibility team to find the best approach. Making the activity feed filter posts by language requires changes in BuddyBoss and further development.

Our compatibility team is planning to get in touch with the author regarding it. Currently, there is no known workaround.

This process may take a while, depending on different factors. It can also not be handled if the author is not cooperative or interested.

You will be notified in this support ticket when we have news. I appreciate your understanding.

June 27, 2023 at 3:51 pm #13904627

mykolaK-6

Hello Andrey!

Thank you for the response.
Is that possible to fix this via some custom code?

Would appreciate any ideas or points in the right direction.

Best regards,

June 28, 2023 at 2:11 pm #13910791

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Yes, it is possible to fix it with the custom code, but there is no straightforward solution, which means not just a matter of a simple WP or WPML hook. Let me explain.

BuddyBoss uses it is own database table called wp_bp_activity. In this table, the BuddyBoss plugin stores every user activity. E.g.

- new_blog_post
- last_activity
- friendship_created
- activity_update
- joined_group

It does not have any language information. They should include data in some other way (possibly JSON data) to support that. This requires some changes in BuddyBoss.

We've got our API https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/ in case you find a way to work around this.

You can also write to the author and explain your issue.

I hope this information helps.

June 29, 2023 at 7:59 am #13915593

mykolaK-6

Thank you for the details, Andrey!
I think the activity should contain some link to the underlying post as a relationship, so all the information about the post should be available already...

Once I found a way to determine the activity language, which hook should I use to apply filtering to the activity feed?
I think WPML should have some code for this, which is used for the news feed. If it's possible, could you point to that code?

June 30, 2023 at 9:52 am #13922451

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for your feedback.

Here are a few things I can mention:

- General overview of what WPML has under the hood

https://wpml.org/documentation/support/wpml-tables/

- How to retrieve posts in a specified language

https://wpml.org/wpml-hook/wpml_object_id/

- If talking about class WP_Query {}, suppress_filters should be false to filter the posts (by default, it is false). As mentioned before, I do not think the feed uses WP_Query, but it is its own table.

https://developer.wordpress.org/reference/classes/wp_query/

Developers Information:
https://wpml.org/documentation/support/

July 2, 2023 at 10:27 am #13928961

mykolaK-6

Thank you, Andrey!

Looking into this already. Please keep this ticket open, I think I may have more questions once I get down to the code itself.

Best regards,

July 3, 2023 at 2:53 pm #13934311

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thanks. This ticket will be open for some time and may be closed by the system automatically due to inactivity.

July 3, 2023 at 5:19 pm #13935411

mykolaK-6

Just fyi, Andrey

Below is my question to the BuddyBoss support team. If you think it's not what I am looking for please let me know.

> Thank you for providing these details. Actually, I don't need translation, I need filtering, so the pseudocode should look like this:

    add_filter('before returning activities to the FE', function ($activities) {
        $selected_lang = $POST['lang'] || wpml_get_default_lang();
        $activities = array_filter($activities, function ($activity) {
            $post = bp_get_post_of_activity($activity);
            if (!$post) {
                // This is a regular activity, do not filter out.
                return true;
            }
           return  $post->lang == $selected_lang;
        });
        return $activities;
    })

> So, in short, I need to know the name of the filter ('before returning activities to the FE') and the function `bp_get_post_of_activity`.

July 4, 2023 at 6:31 am #13937211

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for keeping me updated.