Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

p4004 on "[Plugin: ALO EasyMail Newsletter] Can't get current locale (trying to implement Polylang)"

$
0
0

Hello,

I am trying to modificate plugin to be at least a bit compatible with Polylang plugin.

I am getting a strange behaviour when trying to get current locale when using filters in functions.php, or even if hardcoding it in plugin code. If I come and browse my site, the correct locale is not retrieved. If I change language, when the locale is set. If I change back to initial language, locale is also set well.

Here are my functions:

functions.php:

function kcsite_alo_easymail_get_language(){

	return pll_current_language('slug');     //doesn't always work
	//return substr(get_locale(), 0, 2);     //doesn't always work
	//return 'lt';                            //works
}
add_filter ( 'alo_easymail_multilang_get_language', 'kcsite_alo_easymail_get_language' );

function custom_easymail_new_subscriber_is_added($subscriber, $user_id=false){

	$lang = pll_current_language('slug');
	$lang = (string)$lang;

	global $wpdb;
    $wpdb->update($wpdb->prefix.'easymail_subscribers', array('lang' => $lang), array('ID' => $subscriber->ID));
}
add_action('alo_easymail_new_subscriber_added',  'custom_easymail_new_subscriber_is_added', 10, 2 );

Am I doing it in the proper way, or did I miss something?

http://wordpress.org/extend/plugins/alo-easymail/


Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>