Make WordPress Core

Opened 10 years ago

Closed 7 years ago

#2467 closed defect (bug) (fixed)

Spaces in nicknames and author pages

Reported by: joelgilmore Owned by:
Milestone: 2.6.1 Priority: normal
Severity: major Version: 2.3.3
Component: Template Keywords: author, space, 404
Focuses: Cc:


It seems that when an user's username contains spaces (e.g., "Bob Smith"), links to their author page of the form /author/bob-smith/ fail (these are the types of links produced from within wordpress) and go to the 404 page. This can be fixed by editing the get_userdatabylogin function and changing

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'") )`

But I'm not clear whether this is an appropriate change, or not. Hope this is of some use.

Change History (10)

#1 @davidhouse
10 years ago

  • Resolution set to invalid
  • Status changed from new to closed

What function are you using to generate the links to your author archives? Exactly what are the links? I can't replicate on latest svn using wp_list_authors(). Closing, reopen if you can provide a scenario where this actually fails.

#2 @joelgilmore
10 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

I was using

<?php wp_list_authors('exclude_admin=0'); ?>

This is what happens for me on the latest 2.01 build:

  • Create new user with user name "Bob Smith" (no quotes)
  • Write one post with them as author
  • Try to access their page with the link of form www.myblog.com/author/bob-smith/, returned by wp_list_authors, using all default permalink structures, etc.
  • No joy getting the corresponding author page if the username had spaces in it; no problem for one word.

I'd made a default a custom author page, but I don't imagine that's necessary.

The function get_author_link (in template-functions-author.php) seems to return a link using user_nicename, whereas get_userdatabylogin (in pluggable-functions.php) looks up the database with user_login instead. I'm not really clear where/how user_nicename is set, but it seems that if the link is generated using that field, that's what we should look up in the database.

Of course, it's equally possible I'm missing something completely...!

#3 @joelgilmore
10 years ago

Okay, I'm an idiot - it applies when you change the permalink structure to "Date and name based". Otherwise, links are of the query form, rather than /author/name form.

#4 @rob1n
9 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

It doesn't make any sense. For starters the username shouldn't contain spaces, and why would you use nicename when you want the *username*?

#5 @angelic007
8 years ago

  • Component changed from Administration to Template
  • Keywords author space 404 added
  • Milestone set to 2.5
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version changed from 2.0.1 to 2.3.2

I still have this problem with WP 2.3.2, using function the_author_posts_link() inside template files. The link generated is, for example, http://www.angelic.it/author/G.%20Finamore , that returns a 404. Also http://www.angelic.it/author/G.-Finamore (manually inserting it) doesn't work.

There are recent posts on support forum, too:

#6 @lloydbudd
8 years ago

  • Milestone changed from 2.5 to 2.6

#7 @angelic007
8 years ago

  • Version changed from 2.3.2 to 2.3.3

#8 @thee17
7 years ago

I just confirmed this %20 works - doesn't. It goes - by default on the link instead of %20. I think it is the period in the last post that makes his not work.

#9 @thee17
7 years ago

  • Severity changed from minor to major

#10 @azaozz
7 years ago

  • Milestone changed from 2.9 to 2.6.1
  • Resolution set to fixed
  • Status changed from reopened to closed

Seems to be fixed. Using the_author_posts_link() displays the author's name and uses user_nicename for the link, which is sanitized and doesn't contain spaces or dots.

Note: See TracTickets for help on using tickets.