Page 1 of 1

*Solved *FEU: getting the username.

Posted: Wed Dec 23, 2009 1:50 pm
by Akonkagva
In FEU to print username we simply use {username}.
I need to create little user defined tag which would use logged in user as it's username and add it to SQL.
Example:
$username1 = "uca";
$password = "Example";
$host = "localhost";
$database = "uca";

// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username1, $password);
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
echo "Username".$username;
$query ="SELECT * FROM cms_module_feusers_users_paid WHERE 'username' = {$username} and 'sms_paid_one' = 1";
echo $query;
mysq;_query(..........
$id = mysql_num_rows($results);
if($id > ...........
How can I modify my code to make it display correct SQL with $username inside it ?

Re: FEU: getting the username.

Posted: Wed Dec 23, 2009 2:22 pm
by Peciura
Install module customcontent
http://dev.cmsmadesimple.org/projects/customcontent

Read module help, also search forum for

Code: Select all

$ccuser->property('propertyname')
$ccuser->loggedin()
$ccuser->memberof('group')
$ccuser->username()
Note tags like

Code: Select all

{$customcontent_loginname}
{$customcontent_loggedin} 
are deprecated.

Re: FEU: getting the username.

Posted: Wed Dec 23, 2009 5:26 pm
by Akonkagva
Sorry, I am still confused.

How can I just add current logged in username into sql statement. As in sql provided ?

Thank you for your patience.

Re: FEU: getting the username.

Posted: Wed Dec 23, 2009 5:41 pm
by Akonkagva
Let's make task even more simple:
{php}$thisStringShouldContainUsername = {$customcontent_loginname}{/php} // Big mistake
How to do something like this ?

Re: FEU: getting the username.

Posted: Wed Dec 23, 2009 8:20 pm
by Peciura
Let's make task even more simple:
{php}$thisStringShouldContainUsername = {$customcontent_loginname}{/php} // Big mistake
How to do something like this ?

Code: Select all

{php}
global $gCms;
$smarty = $gCms->GetSmarty();
$thisStringShouldContainUsername = $smarty->get_template_vars('customcontent_loginname');
{/php}

OR your SQL statement can be in UDT.
If your UDT is

Code: Select all

{my_udt my_parameter='some_value'}
In UDT parameter can be accessed this way

Code: Select all

$params['my_parameter'];
More info about UDT at http://wiki.cmsmadesimple.org/index.php ... fined_Tags

Re: FEU: getting the username.

Posted: Wed Dec 23, 2009 8:59 pm
by Akonkagva
{php}
global $gCms;
$smarty = $gCms->GetSmarty();
$thisStringShouldContainUsername = $smarty->get_template_vars('customcontent_loginname');
{/php}
Doesn't work, I have installed both Feu, and Custom Content. Cashable set to false.

Re: FEU: getting the username.

Posted: Wed Dec 23, 2009 9:04 pm
by Dr.CSS
You most likely have a problem from using {php}...

Re: FEU: getting the username.

Posted: Wed Dec 23, 2009 9:44 pm
by Akonkagva
Yes, in UDT after a bit reworking it works fine ! Thank you guy's ! I really needed your help !

Re: FEU: getting the username.

Posted: Thu Dec 24, 2009 4:50 pm
by Dr.CSS