Ticket #2467 (closed defect (bug): fixed)

Opened 6 years ago

Last modified 4 years ago

Spaces in nicknames and author pages

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

Description

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

to

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

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

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.

  • Status changed from closed to reopened
  • Resolution invalid deleted

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...!

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.

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

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*?

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

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:  http://wordpress.org/support/topic/127336

  • Milestone changed from 2.5 to 2.6
  • Version changed from 2.3.2 to 2.3.3

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.

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

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.