Info
- 9 posts
- 5 voices
- Started 2 years ago by Dailytalker
- Latest reply from glatze
- This topic is resolved
Umlaut in member name
-
- Posted 2 years ago #
Hi, when I have an umlaut in a membername it gives me this sign: �
Example: If there is a member with the name "Müller" it shows "M�ller".
How can I replace that � sign with the correct umlaut?
umlauts: ä, ö, ü
-
- Posted 2 years ago #
Strange is that this problem occurs only with member names. In the forum posts the umlauts are displayed correctly.
I use wordpress integration...in wordpress the member names are displayed correctly. Only in bbpress the umlauts are not displayed correctly in the member names.
-
- Posted 2 years ago #
That sounds like an old problem with integration. Can't find the thread right now though.
-
- Posted 2 years ago #
-
- Posted 2 years ago #
I looked a bit around and found a peace of code with which I was able to create a plugin.
<?php
/*
Plugin Name: UTF-8 usernames
Description: This plugin enables utf-8 characters in usernames. Mbstring must be enabled in the php.ini.
*/function sanitize_user_mbstring( $raw_username, $username, $strict = false ) {
$raw_username = $username;
$username = strip_tags($username);
// Kill octets
$username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);
$username = preg_replace('/&.+?;/', '', $username); // Kill entities// Usage of 'mb_ereg_replace' instead of 'preg_replace' to preserve accents.
if ( $strict )
$username = mb_ereg_replace('|[^a-z0-9 _.\-@]|i', '', $username);return apply_filters('sanitize_user_mbstring', $username, $raw_username, $strict);
}
add_action('sanitize_user', 'sanitize_user_mbstring', 0, 3);
?>Unfortunately it doesn't work properly. When it displays correctly in bbpress it doesn't in wordpress and reverse. I don't have access to the php.ini. Could it be, that the thing with "mbstring" is the problem?
-
- Posted 2 years ago #
Ensure that your forum's encoding is utf-8
-
- Posted 2 years ago #
I have in both...UTF-8 but it doesn't work.
-
- Posted 2 years ago #
I solved the problem by adding the following additional code to the plugin:
add_filter( 'get_user_display_name', 'rk_display_name' );
function rk_display_name($name, $ID = 0) {
if ( !seems_utf8( $name ) )
return utf8_encode( $name );
return $name;
} -
- Posted 12 months ago #
We needed to add another filter, so the code looks like this:
add_filter( 'get_user_display_name', 'rk_display_name' );
add_filter( 'get_post_author', 'rk_display_name' );function rk_display_name($name, $ID = 0) {
if ( !seems_utf8( $name ) ) {
return utf8_encode( $name );
}
return $name;
}
-
You must log in to post.