Profile Plugin

pinec1975 11 Oct, 2010
Hi
I am trying to create a form that looks up name on two different fields from the Juser database, can any one advise how to do this

thanks

chris
GreyHead 12 Oct, 2010
Hi chris,

Usually you can get all of the User information from the Joomla! JUser Object e.g.
<?php 
$user =& JFactory::getUser();
echo $user->name;
echo $user->id;
?>


Bob
pinec1975 12 Oct, 2010
Hi Bob
Thanks for the reply, I have got that to work to populate withthe logged in user. Is there a way to read all users and select them from a drop down list ?

Sorry if these seem easy or stupid questions, I am new to this and trying to incorporate a form on a charity website

Thanks

Chris
GreyHead 12 Oct, 2010
Hi Chris,

Yes you can - gets a bit long if you have many users though. What exactly do you need to do here?

Bob
pinec1975 12 Oct, 2010
Hi Bob
Thanks for the reply the first part is now fine as it takes the name from the logged in User. I need a second field named "riders Name" that will give me a drop down box with all users registered in Juser

Thanks
Chris
GreyHead 16 Oct, 2010
Hi Chris,

Try
echo JHTML::_('list.users', 'user_id', true);


Bob
pinec1975 18 Oct, 2010
Hi Bob
Thanks for the code, but it only picks up users that are authors or above, I would like it to read registered users as well ?

Thanks

chris
GreyHead 19 Oct, 2010
Hi chris,

My oversight - needed to look deeper in the docs:
echo JHTML::_('list.users', 'user_id', true, 0, NULL, 'name', false);
should do it.

Bob
soloWP 22 Oct, 2010
Thank you very much, it's just I needed
pinec1975 06 Nov, 2010
Hi Bob Thanks for the info before, I just have one last query I have the following set which shows all the registered users but when the form is saved and exported to Excel the rider_name field only shows the user_id from J-User. Can I change this to show the Actual Name
<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Rider Name</label> 
    <select class="cf_inputbox" name="rider_name"<?php echo JHTML::_('list.users', 'user_id', true, 0, NULL, 'name', false); ?>
  </div>


Thanks
GreyHead 06 Nov, 2010
Hi pinec1975 ,

Not using the JHTML code. Probably the best way is to do the conversion when the form is saved. Use the id to look up the name from the OnSubmit Before box and save that in an extra column in the database.

Bob
kayrie 30 Dec, 2011
Thank you bob. I get it.
But if i want to list all the id of user, how does it happen?
Because this only shown list of user name.
Really appreciate.
Thank You.
kayrie 30 Dec, 2011
Hi Bob
[list]Hi pinec1975 ,

Not using the JHTML code. Probably the best way is to do the conversion when the form is saved. Use the id to look up the name from the OnSubmit Before box and save that in an extra column in the database.

Bob[/list]
How does this happen on chronoform v3?
GreyHead 30 Dec, 2011
Hi Kayrie,

Aren't the ids in the values?

You can build your own query to get the info from the jos_users table if you prefer.

Bob
This topic is locked and no more replies can be posted.