Hi gtownwebdev,
If you have accessed the Joomla User object with say $user =& JFactory::getUser(); then the name is availalbe as $user->name and the email as $user->email, etc.
Use print_r with the User Object to see all the variables; or check the Joomla docs.
Bob
Hi gtownwebdev,
Sorry for the delay - it's been the Xmas holidays over here and my wife has had other plans for me . . .
You don't need the user id in the url = you can look it up at the beginning of the Form HTML if that is what you need. Search here on 'getUser' for dozens of examples.
Bob
I AM using getUser. That's how I'm pulling in the name and e-mail. But I can't seem to pull in District, which is from ANOTHER table, without putting the user ID in the URL.
Here's the code:
Your Name: <b><?php echo $user->name; ?></b> *<br>
Your Email: <b><?php echo $user->email; ?></b> *<br>
Your District: <b>{District}</b> *<p>
Name and Email show up for any logged-in user. But District is from another table, and only shows up if user ID is in the URL. I tried changing District to:
Your District: <b><?php echo $add_masc_member->District; ?></b>
and that doesn't work. Is there a way to get District (which is NOT in jos_user) without calling it via the URL?
Hi gtownwebdev,
You are correct, the \__ should be #__ (my keyboard has switched from UK English to US English for no apparent reason). :-(
Bob
I had tried that earlier -- saw the # on another post in the forum and figured might as well see. Tried it again now and it still doesn't return a result. Then I thought maybe there's an extra semicolon after the WHERE but whether it take it out or leave it, no luck.
Arrgghh!!!! What can it be??!!!!!!
I don't even know how to debug the PHP part.
Does the Profile plugin have any effect here (or can it be of any help)? I had been using it to get that District field -- so it's enabled and has cf_user_id as the target and user_id as the parameter. Maybe that's doing something?
I didn't know that! WHOOPS. I thought the formatting got corrupted! I fixed that and thought NOW it will work ... but no.
Then I realized maybe the match must be wrong. I think it should be cf_user_id, like this:
WHERE `cf_user_id` = ".$user->id." ;
Because the field in add_masc_member that matches the id field in jos_user is cf_user_id. I should have realized that earlier.
But ... still nothing is being returned. Maybe it's not pulling in the jos_user ID right? I don't even know how to debug it -- I just keep going in and changing things without really knowing what I'm doing. I have probably gone in and changed something and saved that form 200 times today. I'm at a total loss with what should be such a simple query!!!!!! Please, please, take a look at the code and help me. I don't know what to do.
Hi gtownwebdev,
It's late here now. The easiest thing to do is to turn on Site debug and look for the query in the output, copying and pasting it into PHPMyAdmin may help to see an error message if there isn't an obvious error.
Bob
Hi gtownwebdev,
Glad you got this working.
The table prefix (usually 'jos_') is used to identify all of the Joomla related tables in the current database schema. It can be changed so that you could have more than one copy of joomla running from the same schema with each identifying it's own tables from the prefix.
The prefix is set on installation and can be changed in the site Global Configuration. All the Joomla database functions know to change it for the current site value before passing the query to MySQL.
Bob