• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Pre-fill Name & email address if user is logged in

Re:Pre-fill Name & email address if user is logged in 15 years 2 months ago #6458

  • kyr34
  • kyr34's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
$my=& JFactory::getUser();
if($my->id)
{ foreach($fields as $i=>$field){ 
if($field->name=='E-mail') $fields[$i]->default_value = $my->get('email');
if($field->name=='Name') $fields[$i]->default_value = $my->get('name'); 
}
}
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 15 years 1 month ago #6739

Setting the default value to {jos_name} doesn't work..it just sets the default to '{jos_name}'

The code above doesn't work either. I get an error every time. Does anyone actually have this working and can submit an actual solution for RSForm Pro?
Last Edit: 15 years 1 month ago by anthony.massa.
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 15 years 1 month ago #6854

Using the following code in the default value, I get the user name on the form, but it's not in the text box. It's at the top of the form?
//<code>
$user =& JFactory::getUser(); echo $user->name;
//<code>
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 15 years 1 month ago #6855

I Found A Way To Make It WORK!

First I installed the Sourcerer plugin found http://www.nonumber.nl/sourcerer. Enable the plug, and settings. Note under Advanced Parameters> Enable in components: Yes, and check mark RSForms Pro.
The Sourcerer plugin, us used to place code in articles, modules, and components.

Next RSforms Pro, Manage Forms> Components in the field default value enter this code:
 
{source}
<?php $user =& JFactory::getUser(); echo $user->name; ?>
{/source}
 

The back end preview you see the code in the element, but the front end you get the user name. This also works with the following fields:

id
name
username
email
password
usertype
block
sendEmail
gid
registerDate
lastvisitDate
activation
params

This also gives you a bigger range of options!
Check out this tutorial on adding more fields to the Joomla 1.5 Registration page: http://www.dart-creations.com/joomla/joomla-tutorials/adding-more-fields-to-the-joomla-registration-page.html. I added, phone, address, city, state, zip fields, and call them with the above method, and it pre fills the fields!!!
Last Edit: 15 years 1 month ago by RadVaWeasel.
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 14 years 7 months ago #8340

  • monashgk
  • monashgk's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
Joomla 1.5.14
RSFromPro! 1.2.0 rev 25

As a follow up to the last post anyone looking for an auto fill using Community Builder (CB), you can use the same plugin as above and the following code to insert any value from the jos_comprofiler table into a text field/textarea. Unfortunately I haven't got this working with dropboxes since there is no box to define the default value. Inserting the code on the first line just leaves you with a mess of code.

How to use:
1. Install the Sourcer plugin as per the post above
2. Create your textfield/area in RSFormPro.
3. Paste the below code into the 'Default value' box for the field. Note: {source} tags are defined in the sourcer plugin - if you leave it default this code will work as is.
4. Change 'cb_fieldname' on line 11 to the cb field you want to fill the form with.
{source}
<?php
global $database, $my;
$mydata = $my->id;
if($mydata!=0)
{
$data = "SELECT * FROM jos_comprofiler WHERE id = $my->id";
$result = mysql_query($data);
$info = mysql_fetch_array($result);
 
echo $info['cb_fieldname'];
}
?>
{/source}

If anyone has a solution for a dropbox it would be most appreciated.
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 14 years 7 months ago #8445

  • wsimpson
  • wsimpson's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
President,
Do you have this working? I can't seem to get this up and running. PHP seems OK but the database query seems to not be working right. Is there some permissions? I have installed the Sourcerer plugin and that seems to work fine but I get no data back into the field and no errors.
HELP PLEASE...
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 14 years 6 months ago #8518

  • monashgk
  • monashgk's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
OK since I made that post I have changed the code I am using.....

//<code>
global $my;
$myid = $my->id;
if ($myid > 0)
return @mysql_result(mysql_query("SELECT `cb_fieldname` FROM `jos_comprofiler` WHERE `user_id`='".$myid."' LIMIT 1"),0);
//</code>

Hope that works for you.
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 14 years 6 months ago #8519

  • monashgk
  • monashgk's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
Sorry....
//<code>
global $my;
$myid = $my->id;
if ($myid > 0)
return @mysql_result(mysql_query("SELECT `cb_memberid` FROM `jos_comprofiler` WHERE `user_id`='".$myid."' LIMIT 1"),0);
//</code>
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 14 years 6 months ago #8772

  • joseph.lalgee
  • joseph.lalgee's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
Although the previously submitted solution didnt work for me (edit: in RSForm Pro), the following did:
//<code>
$user = $RSadapter->user(); 
$myid = $user['id'];
if ($myid > 0) return @mysql_result(mysql_query("SELECT `cb_fieldname` FROM `jos_comprofiler` WHERE `user_id`=".$myid." LIMIT 1"),0);
//</code>

where cb_fieldname is the name you gave the field in community builder
Last Edit: 14 years 6 months ago by joseph.lalgee.
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 14 years 3 months ago #9468

  • mikebosh
  • mikebosh's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
Hi

Have followed instructions in field just get "<!-- Comment - Sourcerer: REMOVED ALL, NOT ENABLED -->" any idea what i am doing wrong


Thanks
Mike
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 13 years 9 months ago #10738

  • WillRoz
  • WillRoz's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Has anyone figured this out yet? Sourcerer is working OK, and I get no error messages, just the code showing in the front end of my form. Any suggestions please?
The administrator has disabled public write access.

Re:Pre-fill Name & email address if user is logged in 11 years 11 months ago #17258

  • sandstorm871
  • sandstorm871's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 1
RadVaWeasel wrote:
I Found A Way To Make It WORK!

First I installed the Sourcerer plugin found http://www.nonumber.nl/sourcerer. Enable the plug, and settings. Note under Advanced Parameters> Enable in components: Yes, and check mark RSForms Pro.
The Sourcerer plugin, us used to place code in articles, modules, and components.

Next RSforms Pro, Manage Forms> Components in the field default value enter this code:
 
{source}
<?php $user =& JFactory::getUser(); echo $user->name; ?>
{/source}
 

The back end preview you see the code in the element, but the front end you get the user name. This also works with the following fields:

id
name
username
email
password
usertype
block
sendEmail
gid
registerDate
lastvisitDate
activation
params

This also gives you a bigger range of options!
Check out this tutorial on adding more fields to the Joomla 1.5 Registration page: http://www.dart-creations.com/joomla/joomla-tutorials/adding-more-fields-to-the-joomla-registration-page.html. I added, phone, address, city, state, zip fields, and call them with the above method, and it pre fills the fields!!!
The administrator has disabled public write access.

Re: Pre-fill Name &amp; email address if user is logged in 11 years 10 months ago #17447

  • Bas103
  • Bas103's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
I'm quite new here but i find that this is exactly what i need.

I have a Joomla 1.5.15 site with RSForm! (not the Pro version)
I have several forms on the site
everything is functioning fine,
But I would like the site to automaticly suggest (or fill) the user name and e-mail adres of the logged-in user
I find the code in previous post understandable,
but i can not figure out where i should put the code!
I tried almost every option in the form but nothing seems to work.

I installed the sourcerer plugin, but I can't find Advanced Parameters in the plugin so that line doesn't work for me

Please help me

Bas 103
Bas 103
The administrator has disabled public write access.

Re: Pre-fill Name &amp; email address if user is logged in 11 years 2 weeks ago #22396

  • MPRC
  • MPRC's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
This is exactly the issue I am having. I posted elsewhere for assistance too.
The administrator has disabled public write access.

Re: Pre-fill Name &amp; email address if user is logged in 11 years 2 weeks ago #22400

  • octavian
  • octavian's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 783
  • Thank you received: 110
You don't need any 3rd party extensions to do this. Please read this article
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
The following user(s) said Thank You: thanos.lygdas
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!