Welcome to the Question2Answer Q&A. There's also a
demo
if you just want to try it out.
Login
Login
Register
All Activity
Questions
Hot!
Unanswered
Tags
Users
Ask a Question
About
Wiki
Welcome to the Q&A for
Question2Answer
.
If you have questions about the platform,
click here to ask
and please use English.
If you just want to try Q2A, please use the
demo
, which also grants admin access.
Apr 29:
Q2A 1.5.2
Related questions
How would I make an "ask a question" form using GET instead of POST?
How do I edit this so it displays the userid instead of the username/handle
How to find out the post_meta who userid?
How to get the level of the logged in user in a theme?
That file has nothing about avatars, where do I find a list of all the user things QA wants me to keep track of?
How to show userid and location between username and points?
Get the value of a custom field added in profile
How do I edit the user agreement?
How Do I Change The User's URL? Would like it more user friendly.
How can I pre-populate a Q2A database with tags without creating a bunch of posts?
All categories
Q2A Core
(3,252)
Plugins
(356)
How do I get the userid of the author of a post?
+2
votes
Basically I am adding Gravatar support to my the question and answer view and I need to be able to extract the userid of the author of the post (be it a question, answer or comment) so I can call the following function to get their email address:
qa_db_single_select($qa_db, qa_db_user_account_selectspec($userid, true));
Does anyone know a simple way of doing this?
userid
user
gravatar
post
asked
Jul 21, 2010
in
Q2A Core
by
anonymous
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1 Answer
0
votes
Best answer
Currently the raw userid of the author of the post is not passed through to the theme layer. But it is available in qa_post_html_fields(...) in qa-app-format.php, as $post['userid'], so you could do something with it there.
But a better way would be to modify qa_db_posts_basic_selectspec(...) in qa-db-selects.php to extract the author's email address as part of the main query. That will save you having to run lots of individual queries to get the email address of the author for each post. Try adding this:
$selectspec['columns']['email']='BINARY ^users.email';
... after ...
$selectspec['columns']['handle']='BINARY ^users.handle';
Having done that you should be able to access $post['email'] directly from qa_post_html_fields(...) and can use that to add the gravatar HTML as a prefix or suffix to $fields['who']['data'] after it is assigned by the call to qa_who_to_html(...)
answered
Jul 21, 2010
by
gidgreen
Show 3 previous comments
Yes indeed, avatars (via Gravatar or otherwise) are certainly on the roadmap.
Sounds good. You could have radio buttons in the users profile to upload an Avatar or use Gravatar instead. I am very impressed with this project, I look forward to contributing to it in the future.
Please
log in
or
register
to add a comment.