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

I have to hack qa-page-user.php to get an "edit your profile" button onto this page.

I just want to show the edit button if the user sees his own profile.

Question is, how can I find out if he sees his own profile?

 

I tried:

        $userid=qa_get_logged_in_userid();
        if(isset($userid)) {
            $qa_content['custom_btn']='edit button...';
        }        

But this is for every logged in user.

 

Do I have to get the URL and parse the username from their? e.g. http://question2answer.org/qa/user/echteinfachtv+%28Kai%29

Or is there a session variable I can retrieve?

Or ... ?

by
You can use Your own tip
http://www.question2answer.org/qa/23796/tip-core-hack-to-output-userid-in-user-profile-page-only-admin
and compare the logged in user id with the profile user id You have set . I think thats it. The other way goes , as far as I know, over comparing the actual url with the users name, but this may be tricky:

I made it like this

if (qa_is_logged_in())
            {
            $myhandle=basename(qa_path_html(qa_get_logged_in_handle()));
            }

and later on

$myurl=strtok($_SERVER["REQUEST_URI"],'?');
            if ($myurl=='/user/'.$myhandle){
                $this->output('<div class="changeprofile"><p>To change Your profile visit Your <a href="http://mypage.com/account">account</a></p></div>');
            }else{....}
by
Thanks a lot! I cannot believe I did not see this *lol*
And thanks for the other code, might be useful =)

Enjoy Saturday night,
Kai
by
Oh, thanks, but credits are Yours, I just found it thanks to Your superb tip, I had a tough time to find a way to load users favorites without doing two new database calls just to determine the users id of the actual profile...
by

1 Answer

+2 votes
by

Insert after line:
qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'users/add_user_x_favorites', $handle));

This code:

if($userid == qa_get_logged_in_userid()) {
         $qa_content['custom_btn']='<a class="btnblue" style="position:absolute;top:50px;right:0;" href="../account">Profil bearbeiten</a>';
}

 

All credits go to monk333 ! :o)

And now each user has a nice blue edit button for his own profile =)

by
Hi ! searching for the line you stated i found that is now in qa-page-user-profile.php file instead.
...