[themify_is_logged_in]
[php]
// Registrierung über User-Meta Plugin – Eindeutiger Username & Nickname = Displayname
// Profilbearbeitung – Nickname = Displayname
function get_random_unique_username(){
$user_exists = 1;
do {
$rnd_str = sprintf( "%0d", mt_rand( 1000000000, 9999999999 ) );
$user_exists = username_exists( $rnd_str );
} while( $user_exists > 0 );
return $rnd_str;
}
function displayNameToNicknameAndUniqueUsername( $userData ){
if ( isset( $_POST[ ‚display_name‘ ] ) ) {
$userData[ ‚user_login‘ ] = get_random_unique_username();
$userData[ ’nickname‘ ] = $_POST[ ‚display_name‘ ];
}
return $userData;
}
add_filter( ‚user_meta_pre_user_register‘, ‚displayNameToNicknameAndUniqueUsername‘ );
function displayNameToNickname( $userData ){
if ( isset( $_POST[ ‚display_name‘ ] ) ) {
$userData[ ’nickname‘ ] = $_POST[ ‚display_name‘ ];
}
return $userData;
}
add_filter( ‚user_meta_pre_user_update‘, ‚displayNameToNickname‘ );
[/php]
[/themify_is_logged_in]