Forums

Display only user's entries ?

fp25 21 Mar, 2014
Hi !
It's me, again :o

I'm actually trying to display only entires that the user's who is connected entered.
Registred users have access to a form, which record their username and name via hidden fields. Below is the code I used and that was posted by Grey Head (thank you again !) on the forum :

<?php 
if ( isset($form->data['username']) && $form->data['username'] ) {
  $username = $form->data['username'];
  $name = $form->data['name'];
} else {
  $user =& JFactory::getUser();
  $username = $user->username;
  $name = $user->name;
}
?>
<input type='hidden' name='nomUtilisateur' id='nomUtilisateur' value='<?php echo $username; ?>' />
<input type='hidden' name='nomComplet' id='nomComplet' value='<?php echo $name; ?>' />


Now, I would like to add a page for registred users where they can see what they registred.
Then, I'm trying to adapt the code above but I'm stuck.

I don't know how to use "Conditions" under "Model" tab ; I assume I have to put the equivalent of "WHERE nomComplet = nameOfUser" but I don't find the right syntax.
I also struggle to find how tu use variables in the code ; I assume I also have to use it in "Conditions".

Can you help me with that ?
Thank you very much🙂
Max_admin 22 Mar, 2014
Answer
1 Likes
Hi fp25,

The conditions needs this format:

<?php
return array("field" => "value");


So assuming your table has a field for storing users id named "user_id" then the condition should be like this:

<?php
$user = JFactory::getUser();
return array("user_id" => $user->get("id"));


Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
fp25 24 Mar, 2014
Hi !
Thank you very much, it works very well😉
This topic is locked and no more replies can be posted.