if (isset($_POST['langs_list']) && current_user_can('manage_options')) {
    $new_langs = explode(",", stripslashes(trim($_POST['langs_list'])));
    if (!empty($new_langs[0])) {
        for ($i = 0; $i < count($new_langs); $i++) {
            if (strlen(trim($new_langs[$i])) < 2) {
                unset($new_langs[$i]);
            }
            $new_langs[$i] = alo_em_short_langcode(trim($new_langs[$i]));
        }
        $str_langs = implode(',', $new_langs);
        $str_langs = rtrim($str_langs, ",");
        update_option('alo_em_langs_list', $str_langs);
    }
}
// All available languages
$languages = alo_em_get_all_languages(false);
// Text fields for multilangual customization
$text_fields = array("optin_msg", "optout_msg", "lists_msg", "preform_msg", "disclaimer_msg");
// If require to check bounce connection or manually check bounces, first submit form and save options
if (isset($_POST['test_bounce_connection']) || isset($_POST['check_bounces_now'])) {
    $_POST['submit'] = true;
}
if (isset($_POST['submit'])) {
    flush_rewrite_rules(false);
    // reset for newsletter permalink
    // -------- Options permitted to all ('manage_newsletter_options')
    // Tab TEXTS
    if (isset($_REQUEST['task']) && $_REQUEST['task'] == "tab_texts") {
        $activamail_subj = array();
        $activamail_mail = array();
        $optin_msg = array();
/**
 * Save the optin/optout on Registration Form
 */
function alo_em_save_registration_optin($user_id, $password = "", $meta = array())
{
    $user = get_userdata($user_id);
    if (!empty($user->first_name) && !empty($user->last_name)) {
        $name = $user->first_name . ' ' . $user->last_name;
    } else {
        $name = $user->display_name;
    }
    if (isset($_POST['alo_em_opt']) && $_POST['alo_em_opt'] == "yes") {
        $lang = isset($_POST['alo_em_lang']) && in_array($_POST['alo_em_lang'], alo_em_get_all_languages(false)) ? $_POST['alo_em_lang'] : "";
        $fields['email'] = $user->user_email;
        //edit : added all this line
        $fields['name'] = $name;
        //edit : added all this line
        //alo_em_add_subscriber( $fields, 1, $lang ); //edit : orig : alo_em_add_subscriber( $user->user_email, $name , 1, $lang );
        if (alo_em_add_subscriber($fields, 1, $lang) == "OK") {
            do_action('alo_easymail_new_subscriber_added', alo_em_get_subscriber($user->user_email), $user_id);
        }
        // if subscribing, save also lists
        $mailinglists = alo_em_get_mailinglists('public');
        if ($mailinglists) {
            $subscriber_id = alo_em_is_subscriber($user->user_email);
            foreach ($mailinglists as $mailinglist => $val) {
                if (isset($_POST['alo_em_register_lists']) && is_array($_POST['alo_em_register_lists']) && in_array($mailinglist, $_POST['alo_em_register_lists'])) {
                    alo_em_add_subscriber_to_list($subscriber_id, $mailinglist);
                    // add to list
                }
            }
        }
    }
    /*else {
    		alo_em_add_email_in_unsubscribed ( $user->user_email );
    	}*/
}