[Closed] WPML & Subscribe2

Home Support English Support [Closed] WPML & Subscribe2

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

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

MatthewR1

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

Orit

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

icl_admin_language

Let me know if this helps.

March 4, 2011 at 8:53 pm #22828

MatthewR1

@Mihai,
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

Orit

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

Amir
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

icl_admin_language

.
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

get_posts

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:
http://wpml.org/documentation/support/wpml-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

MatthewR1

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

Orit

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&gt; 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

false

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

MatthewR1

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

Amir
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:
http://wpml.org/documentation/support/wpml-tables/

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