Exemplo n.º 1
0
/**
 * Generate a unique WordPress username for the given OpenID URL.
 *
 * @param string $url OpenID URL to generate username for
 * @return string generated username
 */
function openid_generate_new_username($url)
{
    $base = openid_normalize_username($url);
    $i = '';
    while (true) {
        $username = openid_normalize_username($base . $i);
        $user = get_userdatabylogin($username);
        if ($user) {
            $i++;
            continue;
        }
        return $username;
    }
}
Exemplo n.º 2
0
/**
 * Generate a unique WordPress username for the given OpenID URL.
 *
 * @param string $url OpenID URL to generate username for
 * @param boolean $append should we try appending a number if the username is already taken
 * @return mixed generated username or null if unable to generate
 */
function openid_generate_new_username($url, $append = true) {
	$base = openid_normalize_username($url);
	$i='';
	while(true) {
		$username = openid_normalize_username( $base . $i );
		$user = get_userdatabylogin($username);
		if ( $user ) {
			if (!$append) return null;
			$i++;
			continue;
		}
		// TODO: add hook
		return $username;
	}
}