Reputation: 97
3 I have a form I developed on my site but out of joomla structure. on the form, I am trying to call active user data like so:
$user = JFactory::getUser();
echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is {$user->username}</p>";
but I am getting: Fatal error: Class 'JFactory' not found in /home5/onlinepc/public_html/action/subs/custompcorder.php on line 38
custompcorder.php is the name of the form I created line 38 is $user = JFactory::getUser(); I guest I have to include something on my file?
Upvotes: 3
Views: 12725
Reputation: 19733
You need to import the Joomla library to be able to use it's API, like so:
<?php
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__) . '/../../'));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$mainframe = JFactory::getApplication('site');
?>
You may need to change the path on line 2 of the code above depending on where Joomla is located in relation to your custom PHP file.
Upvotes: 10