Support

Account

Home Forums Add-ons Options Page Update Options page for specific language Reply To: Update Options page for specific language

  • This is how the acf added the language for options:
    \api\api-helpers.php:3027

    	    
        // append language code
        if( $post_id == 'options' ) {
            $dl = acf_get_setting('default_language');
            $cl = acf_get_setting('current_language');
        
            if( $cl && $cl !== $dl ) {
                $post_id .= '_' . $cl;
            }    
        }
    

    Basically, acf should automatically resolve if you just pass the ‘options’. However, if you were to update the value in a different language than you are currently on, you can temporarily switch acf’s current language setting.

    For example, if your site’s default language is English. But you are currently in French and try to update the English’s field value, you can:

    
    // store the currently language temporarily
    $real_language = acf_get_setting('current_language');
    
    // trick acf to the language you want
    acf_update_setting('current_language', 'en');
    update_field('field_name', 'some value', 'options');
    
    // switch it back
    acf_update_setting('current_language', $real_language);
    

    I haven’t tested yet, but, should work…

    Cheers