Skip to main content

How to auto populate fields with user data using php in RSForm Pro

Today I'm looking at RSForm Pro. What we want to do is want to auto populate the fields with user data after they have logged in and are ready to fill out the form.

To do this we have to go to RSForm Pro in the back-end of Joomla and click manage my forms.

On the front end I have already created a menu link to an existing form. By default the email field is blank, but we want the users email to be filled in for them.
To do this we will go to the form in the backend, open manage forms, and then select the email text box.

In the default value we will add the following code:

$user = JFactory::getUser();
return $user->get('email');

This will automatically pull the users email and auto populate the form with it.

You can also easily pull the following data
• $user->get('id') = user id
• $user->get('username') = the username
• $user->get('name') = registration full name
• $user->get('email') = registration email

Hit save and check it on the front end.

Need more explanation? Watch the video.