Joomla user data into CFv6 form field

doromi 26 Jul, 2018
Hi,

I'm trying to get the data of logged-in people into a form.

I put a custom code into the load part of my form on top of the display section:

<?php
$user =\JFactory::getUser();
$user_id= $user->get('id');

if ($user_id <> "")
{
$vollname= $user->get('name');
$nachname= trim(strrchr($vollname,' '));
$vorname= substr($vollname, 0, strlen($vollname)-strlen($nachname)-1);
$teilnehmer = $nachname .", ".$vorname;

$this->data("teilnehmer", $teilnehmer);
}

I do get the data in the way I need them, but I don't know how to put them into the form field "teilnehmer",
so I assume the last code line is not correct.

Could anybody please tell me how to get the $teilnehmer into the text field "teilnehmer" ?

Thanks in advance,

Doris

healyhatman 26 Jul, 2018
You can just use the shortcodes. In the text box under "value" put {user:name}
healyhatman 26 Jul, 2018
Answer
In PHP to set the data use $this->data("field", "value", true);
​
Or return the value you want and then in value put {var:phpname}
doromi 26 Jul, 2018
Hi healyhatman,
​
thanks a lot - I got it working!
​
Doris
This topic is locked and no more replies can be posted.