I have a form that can only be used by registered users.
When they submit the form they need to enter there name and e-mail again. Is it possible to set the form us so that it gets their e-mail and personal details from the joomla system?
When they submit the form they need to enter there name and e-mail again. Is it possible to set the form us so that it gets their e-mail and personal details from the joomla system?
Hi abasel,
Sure, you are probably using $my (or $user) to check for registration, you can use values from $my in your form html
Bob
Sure, you are probably using $my (or $user) to check for registration, you can use values from $my in your form html
<?php
global $my;
?>
<input type="text" name="email" value="<?php echo $my->email; ?>" />
. . .
You may need some checking to avoid error messages but the principal works well.Bob
Thanks, but I'm a little slow....
1) How do I know if I'm using $my or $user
2) How do I know what the actual field names are? $my -> firstname etc
:-)
1) How do I know if I'm using $my or $user
2) How do I know what the actual field names are? $my -> firstname etc
:-)
k.. but simply trying $my it worked for e-mail...... can't work out the name fields ie those for iether full name or (sur and first separately)
Can I do a similar thing but this time pull details from community builder?
Can I do a similar thing but this time pull details from community builder?
k.. but simply trying $my it worked for e-mail...... can't work out the name fields ie those for iether full name or (sur and first separately)
Can I do a similar thing but this time pull details from community builder?
$my or $user depends on your joomla version, $my worked then you have joomla 1.0.x
$my is loaded with email, id, gid only i think, i'm not sure, try to look it at the Joomla API website!
No, to get CB data you will need to do a simple SQL query!🙂
I hope this helps!
Regards,
Max
Thanks again... this is great
$my worked for 1.5 and I got the full name using $my->name
What a greate component :-)
$my worked for 1.5 and I got the full name using $my->name
What a greate component :-)
Hi abasel,
To see what's in an object put a little debug code into your form:
this will work with any variable (provided that you have debug turned on in the General tab). For $my the output looks like
Bob
To see what's in an object put a little debug code into your form:
<?php
global $my;
echo "my: ".print_r($my, true)."<br />";
?>
this will work with any variable (provided that you have debug turned on in the General tab). For $my the output looks like
my: stdClass Object ( [id] => 62 [name] => Administrator [username] => admin [email] => user@example.com [password] => be4790c07c4228f45a07b87167dda14b:lkMRPPR99Srs8W6geCxLiIc5NttEAekA [password_clear] => [usertype] => Super Administrator [block] => 0 [sendEmail] => 1 [gid] => 2 [registerDate] => 2008-03-05 15:26:32 [lastvisitDate] => 2008-07-28 20:46:11 [activation] => [params] => [aid] => 2 [guest] => 0 )
Remember to remove the code once you are done.Bob
Hia,
This thread is dealing with exactly what I want to do... am actually trying to have registered users' submitted content go into the database with their author name and id.
But I'm having trouble seeing $user (or $my) on Beta3 v2 . The code above to show the array works fine on a form I have with chronoforms 2.5, but nothing shows when I run the same in the latest version ... I have debug switched on.
Your help appreciated as ever.
This thread is dealing with exactly what I want to do... am actually trying to have registered users' submitted content go into the database with their author name and id.
But I'm having trouble seeing $user (or $my) on Beta3 v2 . The code above to show the array works fine on a form I have with chronoforms 2.5, but nothing shows when I run the same in the latest version ... I have debug switched on.
Your help appreciated as ever.
show me how you insert it, it should work! insert it into a hidden field!
Hia,
Not sure what you meant by a hidden field. This is what I'm trying at the top of my form:
...but I'm getting nothing back. If it's any use you can see the form under development here: Sample Rego
Cheers
Not sure what you meant by a hidden field. This is what I'm trying at the top of my form:
<p>Debugging:<br />
<?php
global $my;
global $user;
echo 'my name: '.$my->name."<br />";
echo "my: ".print_r($my, true)."<br />";
echo $user->email;
echo $my.".... my<br />";
echo $user.".... user<br />";
?>
</p>
...but I'm getting nothing back. If it's any use you can see the form under development here: Sample Rego
Cheers
if you have Joomla 1.5 then you should replace global $my with $user = JFactory::getUser();
let me know
Max
let me know
Max
:D yep... it was as simple as that... so all I needed to adapt your Submit Content form so the registered and logged in user becomes the Author of the submitted story was
Many cheers!
<?php //at the top of the form
$user = JFactory::getUser();
?>
...
<p>Submitted by: <?php echo $user->name; ?></p>
<input name="created_by" type="hidden" value="<?php echo $user->id; ?>">
Many cheers!
This topic is locked and no more replies can be posted.