Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Is there a URL I can throw the userid in and get the username?

+4 votes
1,384 views
asked Nov 25, 2012 in Q2A Core by q2apro.com

In different scenarios - especially when developping plugins - I find myself going to phpmyadmin, qa_users, searching the userid to get the username (the "handle").

It would be great to have a URL to get the userprofile immediately.

So additionally to: http://www.question2answer.org/qa/user/Scott

it would be great to have: http://www.question2answer.org/qa/userid/101

Who cares as well about that?

2 Answers

+2 votes
answered Nov 25, 2012 by Scott

Personally I would prefer user URLs of the form www.question2answer.org/qa/user/101/scott

The main advantage IMO is when a user changes their username you don't end up with a 404, the new URL would be /user/101/scott-new-name
Just like questions the userid would be looked up so /101/scott-new-name and /101/scott can both return the user page (with a canonical).
 
Anyway, not really an answer to your question, but just my thoughts on the issue.
commented Apr 6, 2014 by Scott
Yes that may happen, but we need to be careful of backward compatibility.

By the way, not sure if this answers your original question, but there is a function to get the username from an ID, check the docs.
commented Nov 23, 2014 by q2apro.com
Hi Scott, hope you can implement the change of the user URL in 1.7 or 1.8. It would help a lot, esp. coding becomes easier, as we thrown in only the userid (like with the questions) and get the page, does not matter what handle is assigend in the url. I love this with the questions, e.g. http://www.question2answer.org/qa/19419/ (without the seo additions), same should work for user URLs. Looking forward to it!
+3 votes
answered Nov 23, 2014 by q2apro.com

You immediately find in the docs the way handle to userid:

qa_handle_to_userid($handle) returns the userid for the user identified by $handle or null if no user matches. This requires Q2A 1.6+, but see also qa_handles_to_userids(...) and qa_userids_to_handles(...) which were added in Q2A 1.5.

http://www.question2answer.org/functions.php

With v1.6 there was a new function implemented for userid to handle:

function qa_userid_to_handle($userid)

which is not yet in the docs.

 

...