Spaces in nicknames: author pages (1 post)

  1. joelgilmore
    Posted 9 years ago #

    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 blah.com/author/admin/, 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 blah.com/?author=6 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?


Topic Closed

This topic has been closed to new replies.

About this Topic