• Hi!

    So, I’ve recently noticed a problem.

    Two users, one with nice_name ‘-4’ and the other with nice_name ‘4’ in the db.

    When you call the query:

    $author = get_user_by( ‘slug’, get_query_var( ‘author_name’ ) );
    $author = $author->ID;

    You only get the the details for the user with nice_name ‘4’. The hyphen is somehow ignored.

    I’d appreciate any thoughts.

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter jfantasybooks

    (@jfantasybooks)

    An update.

    So, I narrowed it down to get_query_var().

    Apparently the function is unable to detect anything starting with ‘-‘.

    So, https://example.com/-x/ will be collected as ‘x’ instead of ‘-x’.

    This has shown to be a problem for users who have registered with login names starting with a hyphen or more than one hyphen.

Viewing 1 replies (of 1 total)
  • The topic ‘Author.php does not pass hyphen in nicename’ is closed to new replies.