Skip to Content Skip to Menu

[SOLVED] User Data problem after loading API

  • nforse
  • nforse
  • OFFLINE
  • Posts: 6
  • Thanks: 1
  • Karma: 0
  • Add-ons
12 years 8 months ago - 12 years 8 months ago #190995 by nforse
I've used the snippets provided by Krileon to include the CB API and to establish the $user object. The issue I'm having is I can only retrieve user data for Administrators, not Registered Users.
Code:
/* start: set up access to CB API */ global $_CB_framework, $mainframe; if (defined('JPATH_ADMINISTRATOR')) { if (!file_exists(JPATH_ADMINISTRATOR.'/components/com_comprofiler/plugin.foundation.php')) { echo 'CB not installed!'; return; } include_once(JPATH_ADMINISTRATOR.'/components/com_comprofiler/plugin.foundation.php'); } else { if (!file_exists($mainframe->getCfg('absolute_path').'/administrator/components/com_comprofiler/plugin.foundation.php')){ echo 'CB not installed!'; return; } include_once($mainframe->getCfg('absolute_path').'/administrator/components/com_comprofiler/plugin.foundation.php'); } /* end */ /* start: establish $user */ $myId = $_CB_framework->myId(); $cbUser =& CBuser::getInstance( $myId ); if ( ! $cbUser ) { $cbUser =& CBuser::getInstance( null ); } $user =& $cbUser->getUserData(); /* end */ /* start: set variables for pdf */ $userFirstName = $user->cb_firstname; $userLastName = $user->cb_lastname; echo $userFirstName; echo $userLastName;

If I'm logged into my site with a regular, registered user those last two echo lines do not produce the user's first and last name, but if I'm logged in as an administrator they do. Why is this?
Last edit: 12 years 8 months ago by krileon.
The following user(s) said Thank You: mtaras

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

  • nforse
  • nforse
  • OFFLINE
  • Posts: 6
  • Thanks: 1
  • Karma: 0
  • Add-ons
12 years 8 months ago #191002 by nforse
Replied by nforse on topic [SOLVED]
The issue was arising from the use of
Code:
$user->cb_firstname
vs
Code:
$user->firstname
. My code was not presenting a user's first name and last name because I was trying to pull data from different (and empty) fields.

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

Moderators: beatnantkrileon
Powered by Kunena Forum