Support

Account

Home Forums ACF PRO Trying to return a user dependent language Reply To: Trying to return a user dependent language

  • I have a way to do it, but it isn’t the most ideal one, because it’s not DRY.

    if ( 'nl' == $key ) {
        add_filter( 'acf/settings/current_language', function() {
            return 'nl';
        } );
    } elseif ( 'en' == $key ) {
        add_filter( 'acf/settings/current_language', function() {
            return 'en';
        } );
    } else {
        add_filter( 'acf/settings/current_language', function () {
            global $sitepress;
            return $sitepress->get_default_language();
        } );
    }