Forums

Syntax to access user's informations in a php function

FloB 29 Jan, 2018
Hello,

I need to display some information via CCv6.
The informations are differents if the user is logged in, is a special logged in user or is not logged.
So I've got 3 different tables :
table 1 : access public allowed
table 2 : access registred allowed
table 3 : access only few registred users according to the user_id

I would like to use a php function in order to display the wanted table, but I don't know how to access the user's information in the php function.
I've tried $this->get('user') or echo "{user:id}" without success.

Could someone help me with the syntax please?
Florence
FloB 29 Jan, 2018
I have managed to retreive the user's informations with
$user = \JFactory::getUser();

However, I can't have the table displayed because the {fn:read_data2}{view:table1} below isn't "translated" when I access the event :
Events
Index
{fn:read_data1}
{fn:php1}
{var:php1}

Views
table1 : to display the read_data2 informations
Functions
read_data1 : to find the user_id for wich the table 1 should be visible
read_data2 : to find the informations displayed in the table1
php1 :
$user = \JFactory::getUser();
$list_userid=$this->get('read_data1');
if(in_array($user->id,$list_userid){
return "{fn:read_data2} {view:table1}";
}else{
//other informations
}


The php1 function is working well because the index event shows either "{fn:read_data2} {view:table1}" or the other informations, but instead of reading "{fn:read_data2} {view:table1}", I would have the table1 displayed...

Thanks for the help,
CCv6 is really amazing, but quite different from CCv5πŸ™‚
Max_admin 30 Jan, 2018
Answer
Hi FloB,
Glad you like v6πŸ™‚
In order to process shortcodes inside PHP code you need to use the following syntax:
return $this->Parser->parse("{view:table1}");
Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.