Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Q2A Core by
Each of my questions will be taken up by one editor. Other users will be able to answer too.

On question pages that the editors answer, I need to be able to credit them in a php session variable set to his/her username  eg:

$_SESSION['author'] = $username;

Which files would I need to look at (anything possible without messing with the core?)

1 Answer

0 votes
edited by
Do you really need a $_SESSION variable, or just a $_POST variable?  Session variables are persistent, if you just need the variable for form processing, add a hidden field to the form:

<input type="hidden" name="author" value="'.get_logged_in_userid().'">

and collect it at processing time with:

$author = qa_post_text('author');
I do need it to be persistent, so how could i achieve this? It would mean editing a file that builds the question viewing?
That depends what you mean by persistent... I still don't think you need a session variable; that only makes it persistent for the current user's session.  If you want to make it truly persistent, you need to collect the $_POST variable and store it in a database.  Come to think of it, this is done for you already.  If you want to know who wrote a post, it's in the database qa_posts under userid.  It'll also be in $this->content['raw']['userid'] for theme layers.

Note: I edited the above answer because I guess you are looking for the currently logged in user's id when they post a question.
edited by
I'm sorry for the confusion, I don't think i've made the situation clear!
I do indeed need the variable to be for the web user's session.

Reason being is that when they go to an affiliate form of mine (same domain but outside QA), I want that session variable to be available to add to my form field.

So browser views question.
If an editor has answered the question (ther will be only one editor for each question although other usertypes may answer), his username gets added to the php session array as eg ['answerer'].
If browser then visits my webform outside QA, then $_SESSION['answerer'] is available to it.

Hope this makes a bit more sense?


Solved by using raw:

            if ($a_item['raw']['level']=="80"){