Using info via php from AjaxRegister

10 years 10 months ago #7256 by lsmac
I created a few new fields with AjaxRegister to help out in identifying my clients abit more 'personally'.  Additional fields are firstName, lastName, companyName, but I am having trouble accessing the info.

I know that in Joomla I can access the username via php with this statement:

<?php $user =& JFactory::getUser(); $userName = $user->get( 'name' ); if ($user->get('guest') == 1) {echo "Greetings, welcome to our great website!"; } else { echo "Greetings ".$userName.", welcome to our great website!"; } ?>

But, what I want to do is echo the firstName field from AjxRegister, rather than username from Joomla profile.

Can anybody help me out with the proper PHP code?  It's all Greek to me, as I am a graphic artist, not a programmer...LOL

Any help is appreciated,

Scott

Please Log in or Create an account to join the conversation.

10 years 10 months ago #7257 by Saka
Hello,

The extra fields are attached to the user object so they can be accessed via:
$user = JFactory::getUser();
print_r($user->extra);

For example, to access your field with label companyName you will do it with:
$user->extra['companyName'];

Emir Sakic
www.sakic.net

Please Log in or Create an account to join the conversation.

About us

We provide high quality Joomla components created by a co-founder and original core developer of Joomla. For over a decade, our products have been used by more than 20.000 webmasters around the world.

Stay in touch