How do I get username

Ronald Austin Posted in General Discussion 4 years ago

I have put a link to a php program on the menu using Menu Builder. In that program how do I get the person's username?

Replies
German Michael Zülsdorff Replied 4 years ago

Sorry Ronald,
but that's beyond my capabilities.
Why don't you have a look into Ossn documentation pages like 'How to write a simple component' and/or investigate components with a similar functionality - as
https://www.opensource-socialnetwork.org/component/view/3752/custom-site-pages
for example?

us Ronald Austin Replied 4 years ago

No, I don't want to pass the username using GET. I wanted to write a component, I just didn't know it. LOL. Can you direct me to a "How to write an OSSN Component for Dummies" tutorial?

German Michael Zülsdorff Replied 4 years ago

I'm sorry, Ronald, got you wrong.

You wanted to create a link like

https://somesite.com?user=ronald

to be retrieved by somesite.com via $_GET['user']

So, that would mean to make the Menubuilder accept a variable link like

<?php echo 'https://somesite.com?user=' . ossn_loggedin_user()->username; ?>

and I don't see any chance that this will ever happen because the Menubuilder would open a wide door for hackers this way ...

So the right solution is to develop a component implementing the code above, and using the menubuilder for a normal hardlink pointing to your component's page.

us Ronald Austin Replied 4 years ago

yes, the I need to get the username of the currently logged on user. Thanks for your answer but it doesn't help much since i have no idea how to call ossnloggedinuser()->username. I assume that I have to load a library. Where do I find the library and how do I load it? Is there documentation somewhere that tells me how to do this?

German Michael Zülsdorff Replied 4 years ago

Which username? The name of the currently logged in user?
If so you can use the returned value calling ossn_loggedin_user()->username