We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

How to get profile user id | Forum

Offir
Offir Apr 16 '13
Hi,


Im trying to create a widget that contains a simple button but I need the username or user ID of the profile that is being viewed (not the current logged in user)


ex) 


If I am on John Doe's profile page, the button needs to say


"Rival John Doe"


Anyone know how I can do this?

Offir
Offir Apr 16 '13
Nvm got it!


Here is the solution if anyone ever needs it :D

$userId = (int) $paramObject->additionalParamList['entityId'];$userName = BOL_UserService::getInstance()->getDisplayName($userId);

DavidZenry
DavidZenry Apr 18 '13
Can you paste that into a Custom HTML widget in the dashboard?

I've tried posting PHP and even OMWL but it doesn't work, I could put an Iframe there but I'm not sure how to link it into the Oxwall user data?
Offir
Offir Apr 22 '13
No, this will only work in PHP, you are able to send variables over to HTML but you will probably have to create your own widget for that. 
Mario Carriere
Mario Carriere Apr 23 '13
Hi,

To get the user Id, you can get it by simply;

$id = OW::getUser()->getId();  

and then get the username with;

$userName = BOL_UserService::getInstance()->getDisplayName($id);

And if you create your instance first to the user service your code could be;

$userservice = BOL_UserService::getInstance(); // this need to be done once at the begining of your code

$id = OW::getUser()->getId();                     // Getting the user ID
$name = $userservice->getDisplayName($id);  // Getting the user name

Mario
Rahul Bhatt
Rahul Bhatt Nov 14 '14
Mario ,


Your code looks perfect. Where I should  put this code if I want to display like Welcome , {$Username} on dashboard?


Please help me.

Mario Carriere
Mario Carriere Nov 16 '14
Hi Rahul,

Sorry about the delay.

To display a welcome message like the one you propose, I would create a small widget. You can find example code for widget in the developer section of oxwall site.

It is not recommended to edit the core files of oxwall to modify it. Plugins or widgets are the way to go.

Start with a small and simple widget and build from that...! :)

Mario
Rajibul Hasan
Rajibul Hasan Mar 17 '15
Thanks Offir, This saved a tons of time for me.. Appreciate your sharing! :)
Quote from Offir $userId = (int) $paramObject->additionalParamList['entityId'];