*

pitbull

  • ***
  • 98 posts
How can i get the username from item page ?
« on: January 27, 2018, 07:30:30 PM »
Hi @Frosticek.
I 'm trying to display 3-4 random listings to the item page of every user. So when someone visit an item page it will display at the bottom:

"CHECK ALSO THESE ITEMS POSTED BY THIS USER"

Item 1
Item 2
Item 3
Item 4

etc

How can i get a user's username from an item? I know that already we can get the author id from an item with this helper:

   
Code: [Select]
<?php echo osc_item_user_id(); ?>
This works fine and display the user id at the item page. But i want to get the unique username(not real name) of the author with something like that:

   
Code: [Select]
<?php echo osc_item_user_username(); ?>
So my question is what is the function for such a helper? How can i query to DB so it will return the user's username based on the item page someone is viewing ?

Thanks.
« Last Edit: January 27, 2018, 07:38:08 PM by pitbull »

Marked as best answer by pitbull on January 28, 2018, 04:05:37 AM
*

MB Themes

Re: How can i get the username from item page ?
« Reply #1 on: January 27, 2018, 11:32:11 PM »
@pitbull
Code: [Select]
$user = User::newInstance()->findByPrimaryKey(osc_item_user_id());
echo $user['s_name'];
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pitbull

  • ***
  • 98 posts
Re: How can i get the username from item page ?
« Reply #2 on: January 28, 2018, 04:06:02 AM »
@pitbull
Code: [Select]
$user = User::newInstance()->findByPrimaryKey(osc_item_user_id());
echo $user['s_name'];


You re the best ;)