Изменить имя пользователя без санитизации для пользователя WordPress - PullRequest
0 голосов
/ 02 мая 2020

Как удалить sanitize из edit_user_profile action?

У меня есть возможность изменить user_nicename с помощью следующего кода:

function ex_insert_nicename_input( $user ) {
    $content = ob_get_clean();

    // Find the proper class, try to be future proof
    $regex = '/<tr(.*)class="(.*)\buser-user-login-wrap\b(.*)"(.*)>([\s\S]*?)<\/tr>/';

    // HTML code of the table row
    $nicename_row = sprintf(
        '<tr class="user-user-nicename-wrap"><th><label for="user_nicename">%1$s</label></th><td><input type="text" name="user_nicename" id="user_nicename" value="%2$s" class="regular-text" />' . "\n" . '<span class="description">%3$s</span></td></tr>',
        esc_html__( 'Name' ),
        esc_attr( $user->user_nicename ),
        esc_html__( 'Unique' )
    );

    // Insert the row in the content
    echo preg_replace( $regex, '\0' . $nicename_row, $content );
}

add_action( 'show_user_profile', 'ex_insert_nicename_input' );
add_action( 'edit_user_profile', 'ex_insert_nicename_input' );

Если я введу «Ab» и обновлю Информация о пользователе это сохранит как "ab". Можно ли отфильтровать этот процесс и очистить текст, но без преобразования букв из прописных в строчные?

enter image description here enter image description here

...