show user id in front end

  • Posts: 27
  • Thank you received: 0
12 years 9 months ago #40809

Hi,
First let me thank you all for a great support, i have learned so much building my system, and when it goes live i will share it with you.
now for my question.

I would like to know if is there any why for me to present the user (after he logged in) every where in the website his hikashop_user_id.

I would like to know how to do that, as there are a couple of custom fields I need to present for the user but it's all connected to hikashop user id and not joomla.

Thanks for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 83023
  • Thank you received: 13403
  • MODERATOR
12 years 9 months ago #41014

When HikaShop is loaded, you can do like that:

$user = hikashop_loadUser(true);
echo $user->hikashop_user_id;

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 0
12 years 9 months ago #41406

What about if hikashop is not loaded?
How do I load it in my module?

Thanks for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 0
12 years 9 months ago #41512

What i meant was, if I wan't to display my module on the homepage, but there is no product/cart/ or any thing from hikashop.
How could I load fast with out needing to do some thing like that:

$user =& JFactory::getUser();
$usercmsid = $user->id;
$username = $user->name;
$jdb =& JFactory::getDBO();
$query = 'SELECT user_id FROM hikashop_user WHERE user_cms_id = '.$usercmsid.'';
$jdb->setQuery($query);
$user_id = $jdb->loadResult();

your code of $user = hikashop_loadUser(true); gives me this error: Call to undefined function hikashop_loadUser()

Thank you very much for your great support, the support is what made me buy this cart and not another one...

Last edit: 12 years 9 months ago by justaguy.

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 0
12 years 9 months ago #41515

ok, I got it working.
here is how I did it:
first, we need to insert the hikashop helper:

if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){
echo 'This module can not work without the Hikashop Component';
return;
};
now, the call for the userid is a little different from what you wrote:
$userhika = hikashop_loadUser(true);
$user_id=$userhika->user_id;
the only difference is that you wrote hikashop_user_id and the correct syntax (at least with this helper.php file) is user_id.

Please Log in or Create an account to join the conversation.

  • Posts: 83023
  • Thank you received: 13403
  • MODERATOR
12 years 9 months ago #41518

Indeed, it's user_id and not hikashop_user_id.

The following user(s) said Thank You: justaguy

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum