Page 1 of 1

Cannot get information from FEU Module

Posted: Wed Dec 05, 2012 1:37 am
by KarlDD
Hello Forum,

I've been having troubles with the FEU module,

First it wasn't able to retrieve the FEU details for the Orders Module order form, but that wasn't a big issue for me.

But not I'm trying to add FEU details to the Admin Email template in the orders module using this UDT but I keep getting the error that it cannot communicate with the FEU Module.

I'm beginning to pull my hair out because I'm not sure how to fix this!

I just want the FEU details to be emailed to the Admin.

My system is as follows:

Code: Select all

CMS Install Information
CMS Version		1.11.3

Installed Modules
CMSMailer		5.2.1
CMSPrinting		1.0.3
FileManager		1.4.2
MenuManager		1.8.4
MicroTiny		1.2.4
ModuleManager		1.5.5
News		2.12.10
Search		1.7.7
ThemeManager		1.1.7
SEOTools2		1.1.1
TinyMCE		2.9.11
CGExtensions		1.31.2
FrontEndUsers		1.21
FormBuilder		0.7.3
CGSimpleSmarty		1.5.2
JQueryTools		1.1.1
Products		2.18.4
CGEcommerceBase		1.3.11
CGPaymentGatewayBase		1.1
Orders		1.13.3
Cart		1.8.4
CustomContent		1.8.3
CGSmartImage		1.9.4

Re: Cannot get information from FEU Module

Posted: Wed Dec 05, 2012 1:33 pm
by Jo Morg
Replace

Code: Select all

global $gCms;
$error = "";
$result = "";
$feusers = $gCms->modules['FrontEndUsers']['object'];
with

Code: Select all

$error = "";
$result = "";
$feusers = cms_utils::get_module('FrontEndUsers');
The UDT code is quite old and the methods deprecated... but the rest should work.

Re: Cannot get information from FEU Module

Posted: Wed Dec 05, 2012 8:29 pm
by KarlDD
Thanks for your reply, that fixed the error, but now I get this error from the UDT:

Code: Select all

[UDT get_feu_properties Error; Missing or empty parameter: username]
Any ideas why?

Thanks,
Karl.

Re: Cannot get information from FEU Module

Posted: Wed Dec 05, 2012 8:40 pm
by Jo Morg
KarlDD wrote:Thanks for your reply, that fixed the error, but now I get this error from the UDT:
Code:
[UDT get_feu_properties Error; Missing or empty parameter: username]
check this bit from the UDT:

Code: Select all

...
   $username = $params['username'];
   if ($username == "") {
      $error = " [UDT get_feu_properties Error; Missing or empty parameter: username] ";
....
$params['username']; is empty...

so it means you have to call the UDT with a paremeter called username
Parameters:

username (required): the Frontend Users username.
property (optional): the name of the property value to return as the result; When not specified, the result will be the Frontend Users uid.
method (optional): when not specified, the result is simply displayed; When method="assign", the value is returned in a Smarty variable with the same name as the property.

Usage:

To display the user id (uid) of a FEU user named "Frank" use:

{get_feu_properties username="Frank"}

To display the value of the property "phone_number" of the user "Jane" use:

{get_feu_properties username="Jane" property="phone_number"}

To assign the value of the property "email_addr" of the currently logged in FEU user use:

{get_feu_properties username=$username property="email_addr" method="assign"}

In this case nothing is displayed but instead the variable "$email_addr" now contains this users' email address.

Re: Cannot get information from FEU Module

Posted: Wed Dec 05, 2012 10:13 pm
by KarlDD
I wanted it to get the details from the logged in user, so this is how I set it up:

Code: Select all

{get_feu_properties username=$username property="first_name"}
{get_feu_properties username=$username property="last_name"}
{get_feu_properties username=$username property="address"}
{get_feu_properties username=$username property="phone"}
{get_feu_properties username=$username property="email"}
Is that not correct? Still have the error :/

Re: Cannot get information from FEU Module

Posted: Wed Dec 05, 2012 10:20 pm
by Jo Morg
Where does $username comes from?
Put {$username} on the template. If it comes empty or null then it's not a valid Smarty variable.
Use {get_template_vars} to check what vars are available to you on a template, on a given context.

Re: Cannot get information from FEU Module

Posted: Tue Dec 11, 2012 8:32 pm
by KarlDD
I'm unsure how to get the username from the currently logged in user, the {$username} tag works in the FrontEndUser module templates but I don't know how to get the same property to work in the UDT, I'm stuck. :/

Re: Cannot get information from FEU Module

Posted: Tue Dec 11, 2012 8:58 pm
by KarlDD
How can I get the username info from the current logged in user into this UDT?

Re: Cannot get information from FEU Module

Posted: Tue Dec 11, 2012 9:48 pm
by rotezecke
it looks like you dont need the username for the script, as the username is later converted to an ID which is what the rest of the script uses.

try this: remove

Code: Select all

   $username = $params['username'];
   if ($username == "") {
      $error = " [UDT get_feu_properties Error; Missing or empty parameter: username] ";
   }
   else {
      $uid = $feusers->GetUserID($username);
and replace with

Code: Select all

$uid = $feusers->LoggedInId();
i didn't quite follow (that is read) the entire post but maybe this helps.

Re: Cannot get information from FEU Module

Posted: Tue Dec 11, 2012 10:29 pm
by KarlDD
ok, well that returns the id of the current logged in user, but if I try display any of the user properties its returns a blank field ?

Re: Cannot get information from FEU Module

Posted: Wed Dec 12, 2012 12:30 am
by calguy1000
How can I get the username info from the current logged in user into this UDT?

Code: Select all

$feu->LoggedInName();

Re: Cannot get information from FEU Module

Posted: Wed Dec 12, 2012 11:55 pm
by KarlDD
I still can't get it to display the selected category, I guess I'm jst going to have to call it quits on this one.

Re: Cannot get information from FEU Module

Posted: Thu Dec 13, 2012 5:46 am
by rotezecke
Assuming you applied the changes I posted before try this.
Add:

Code: Select all

print_r($properties);
after
$properties = $feusers->GetUserProperties($uid);

If that prints ok, work on the if statement within the foreach loop.

Re: Cannot get information from FEU Module

Posted: Thu Dec 13, 2012 9:13 pm
by KarlDD
It's jusst doing the same thing, prints "6" which is the id of the logged in user, but still no properties :/

Re: Cannot get information from FEU Module

Posted: Fri Dec 14, 2012 3:11 am
by rotezecke
hmm.

replace the print_r with:

Code: Select all

echo $feusers->GetUserPropertyFull(first_name,$uid );
or, since you pass on the paramenter when calling the UDT

Code: Select all

echo $feusers->GetUserPropertyFull($params['property'],$uid );