Due to the large volume of support requests, at the moment there is a waiting time of more than 24 hours. We apologize for the inconvenience this causes. We do not have any recurring unknown issues so we encourage you to please search the forum for other support topics that might be helpful and to review our documentation and look at our errata page for known issues. A supporter will respond to you as soon as possible.

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.

This topic contains 8 replies, has 3 voices, and was last updated by  Amir 6 years, 11 months ago.

Author Posts
Author Posts
March 2, 2011 at 9:25 pm #22825


I write Subscribe2, an email notification plugin for WordPress. There seem to be a few users that would like to get WPML and Subscribe2 playing nicely together.
I've accessed you code now (thanks) and have a vague understanding how it works, the translations are stored in the posts table as a new entry.
Subscribe2 takes new posts that are published using the WordPress transition API actions, processes the content a little and generates an email.
Is there a way to filter the content for certain registered users who have entered a language preference? How does WPML allow multilingual access to readers? Is it on a per visit basis, cookies or is there a database setting?

March 3, 2011 at 8:25 am #22827


Hi Matthew - registered users can save their language preference on their profile page. It's saved as a user custom field called


Let me know if this helps.

March 4, 2011 at 8:53 pm #22828


That should help, what are the potential settings? Are they user defined or a set of pre-defined strings for each supported language?

March 4, 2011 at 8:56 pm #22829


Not sure I understand your question.
It's simple as each user having a certain language associated with him as long as he sets it on his profile page.

March 4, 2011 at 9:00 pm #22830

Forum moderator

Mihai is away for the weekend, so I'll help the best I can.
Go to your Profile page. Scroll to the bottom and you'll see the language setting. Switch between languages and see the value of


The best way to filter posts by language would be to set the current language as that language and then just use the WP API calls (like


while applying filters) to query posts. WPML will then filter and keep only results in the selected language.
Alternatively, you can join any table with WPML's language tables:
Mihai will be back here on Monday, so if you need better information from here, add another post and he'll get back to you.

March 8, 2011 at 8:41 pm #22831


Amir / Mihai,
Okay, I've found the language codes now and I'm thinking how I can make use of them within Subscribe2.
Say a WordPress user write and translates their post and hits publish, how do I filter the $post->post_content?
Say the blog is in 3 languages and I have a list of Registered users. I split them into 3 groups - one for each language (taking into account that blank db entries are the default language) - how can I then grab the right post for each language to generate an email?

March 9, 2011 at 12:02 pm #22832


Hi Matthew,

Say a WordPress user write and translates their post and hits publish, how do I filter the $post->post_content?

Still not sure what you need here. There's a WP filter called 'wp_insert_post_data' that is applied right before adding the post to the database.
If I understand correctly what you need here is what you can do: assuming that you need a certain post to subscribers and the post in the default language has the ID=9.
Use <a href="http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/">icl_object_id</a> to get the relevant post for different languages.
So if the user X has the language 'es' associated with him you'll send him the post:

$post = get_post(icl_object_id(9, 'post', false, 'es');

Note that if the third parameter is


and there's no translation in es of the post with the ID-9 icl_object_id will not return anything. Otherwise it would return the ID of the original post (in this case 9).
Let me know if all this makes sense and helps.

May 30, 2011 at 6:56 pm #22833


Nearly there I think. I've created a new class that replaces some of the Subscribe2 functions when running on a WPML WordPress system.
Subscribe2 has 2 email types. Per post sent at the time of publication - for this I think I have code that will work with WPML.
I've also got a digest email though that works on a periodic cron basis collection all entries that are posts (and maybe pages) between 2 dates or times.
Which function within WPML is best to sort the posts between 2 time periods into languages?

May 31, 2011 at 5:54 am #22834

Forum moderator

We didn't create an API function for checking the language of an item. We can add it, but it's not going to be immediate.
You might want to load WPML's language table and lookup the items from there. Here is a description of that table:

The topic ‘[Closed] WPML & Subscribe2’ is closed to new replies.