Support » Fixing WordPress » Spaces in nicknames: author pages

  • Hi all,

    This has been discussed previously, but I can’t find an actual resolution, if any. I’ve made an author page which displays a few details about an author. You get there via, which is what the List of Authors returns. It works just fine populating $curauth for nicknames with no spaces (e.g., ‘test’), but as soon as you add a space, it fails to work (e.g. ‘bob smith’/’bob-smith’). I can still get their author page by going to just fine – it seems to be

    $curauth = get_userdatabylogin(get_query_var('author_name'));

    that’s causing the trouble. The correct author name is being passed, but the function doesn’t return the right thing. I also tried (since someone suggested it)
    $curauth = get_userdatabylogin(get_the_author_login());
    but get_the_author_login returns squat.

    Hacking around in the source, I changed get_userdatabylogin‘s SQL query from

    if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") )


    if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_nicename = '$user_login'") )

    since it seems that nicename is the sanitized version of user_name with hyphens instead of spaces, etc.

    Now, everything works just fine, whether spaces in the username or not. Could someone confirm if this was a bug, or did I miss something? If it’s a fix, who should I let know?


  • The topic ‘Spaces in nicknames: author pages’ is closed to new replies.