Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.2k views
in Q2A Core by

I wanna place some HTML content at the top of user page, however I want this content to be visible to logged in users only (therefore using widget anywhere plugin won't work)

How can I do that please?

Q2A version: qa 1.63 dev

1 Answer

+4 votes
by
selected by
 
Best answer

Maybe adding this to your qa-theme.php file might do the trick:

public function part_title($part) {
    qa_html_theme_base::part_title($part);
    if ($this->template === 'user' &&
        isset($part['fields']['duration']) &&
        qa_is_logged_in())
    {
        $this->output('<div>Some HTML here</div>');
    }
}
by
Worked beautifully! thank you
by
@pupi1985: How did you insert this code in the editor here? I can't see a button for inserting code in the editor.
by
Sadly, there is no way to insert code in this editor :( I make it look that way by setting the font to monospace, making it bold and then turning it to gray... clearly not the answer you were expecting, right? :P

Anyway, it looks much better than the blockquote, IMO.
by
Great idea man! Thanks.
by
@Pupi1985
One thing that i just noticed after actual usage of this code is the following:
After login, it makes sense that i see <div>Some HTML here</div> on my own account page, however if i visit another user's page I dont wanna see the <div>Some HTML here</div> on his account's page. How can i fix that?
Suppose that we replace <div>Some HTML here</div> with something like<b> your score is ^</b>
The we dont wanna see this content on someone else's page. Thank you for your help in advance
by
you mean this?
public function part_title($part) {
       
            qa_html_theme_base::part_title($part);
            if (qa_get_logged_in_handle() === qa_request_part(1))
            {
                $this->output('<div>htmk stuff</div>');
            }
        }
by
I mean this:

public function part_title($part) {
    qa_html_theme_base::part_title($part);
    if ($this->template === 'user' && isset($part['fields']['duration']) &&
        qa_get_logged_in_handle() === qa_request_part(1))
    {
        $this->output('<div>Some HTML here</div>');
    }
}
by
That was it -Thank you
...