Mon. - Fri. 9 am - 5 pm Ask a Question
Remember me

Get Joomla user data from PHP script "After data submission"

2 weeks 19 hours ago #1

  • GOLDEN's Avatar
  • GOLDEN
  • Posts: 6
Hi!

Your product it's geat! But i need some help.

I'm trying to retrieve the Joomla user name to use it in the PHP Scripts "After data submission", but it doesn't work.

This is the code I'm using to test it:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
include("administrator/includes/defines.php");
include("administrator/includes/framework.php");

$user = JFactory::getUser();

$handle = fopen ("test.txt", "w");
fwrite ($handle, 'Joomla user name: ' . $user->username);
fclose ($handle);

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

But the result in the text.txt file it's just a 'Joomla user: '

Why it'snt working?

2 weeks 18 hours ago #2

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 18982
Top includes are not needed.
You need to use the full path
sample code
$user = JFactory::getUser();
$handle = fopen (JPATH_ROOT."/tmp/test.txt", "w");
fwrite ($handle, 'Joomla user name: ' . $user->username);
fclose ($handle);

Alternatively, we can suggest that you use a hidden field with a default value (Username data tag)

More in the documentation
www.balbooa.com/joomla-forms-documentati...joomla-forms-builder

Regards,
Vyacheslav, Balbooa.com

2 weeks 18 hours ago #3

  • GOLDEN's Avatar
  • GOLDEN
  • Posts: 6
Sorry, it works perfectly, even without includes.

I just wasn't signed, My bad.

2 weeks 18 hours ago #4

  • GOLDEN's Avatar
  • GOLDEN
  • Posts: 6
Thanks, Vyacheslav!

I just need a coffee to realize that I wasn't logged. Sorry about making you lose your time.

2 weeks 18 hours ago #5

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 18982
You are welcome ;)
Let us know if you need more assistance!

Best Regards,
Vyacheslav, Balbooa Support Team
Powered by Kunena Forum