Make WordPress Core


Ignore:
Timestamp:
03/27/2020 09:56:24 PM (5 years ago)
Author:
johnbillion
Message:

Users: Add a user language preference option to the "Add New User" form.

This uses the same language selection control as the user editing screen and allows new users to be invited to a site in their own language.

Props barryceelen, johnbillion

Fixes #38665

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/user.php

    r47219 r47516  
    113113    }
    114114
     115    if ( isset( $_POST['locale'] ) ) {
     116        $locale = sanitize_text_field( $_POST['locale'] );
     117        if ( 'site-default' === $locale ) {
     118            $locale = '';
     119        } elseif ( '' === $locale ) {
     120            $locale = 'en_US';
     121        } elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
     122            $locale = '';
     123        }
     124
     125        $user->locale = $locale;
     126    }
     127
    115128    if ( $update ) {
    116129        $user->rich_editing         = isset( $_POST['rich_editing'] ) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
     
    119132        $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
    120133        $user->locale               = '';
    121 
    122         if ( isset( $_POST['locale'] ) ) {
    123             $locale = sanitize_text_field( $_POST['locale'] );
    124             if ( 'site-default' === $locale ) {
    125                 $locale = '';
    126             } elseif ( '' === $locale ) {
    127                 $locale = 'en_US';
    128             } elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
    129                 $locale = '';
    130             }
    131 
    132             $user->locale = $locale;
    133         }
    134134    }
    135135
Note: See TracChangeset for help on using the changeset viewer.