Forums

Getting the current user's records

cruser 01 Aug, 2018
Is there an updated code for CC6? I have a dozen users that submit work orders via CF6. I am trying to set this up so that each submitter will only see their submitted record. In the database I have it setup to store the user id. But for the life of me I just cannot figure exactly where to put the code below. In CC6 I have the General tab, the Events, Views, Functions, Locales, Permissions. Does the code below go in the Functions tab with function of Read Data in the Where conditions box? If so, what is the next step?
<?php
$user = \JFactory::getUser();
return array('model_id.user_id' => $user->id);
?>
I am setting this up in the read data function named "read_myarticles" with a model name Article and placing the code below in the Where conditions box:
<?php
$user = \JFactory::getUser();
return array('Article.user_id' => $user->id);
?>
In my Events tab I have an event named myorders and there I use
{fn:read_myarticles}
I end up with on the preview:

1054 Unknown column 'Article.172' in 'where clause'

172 is an actual user id.

Again, in this event I am trying to get a user to see only his records. Any detailed help is appreciated!
healyhatman 02 Aug, 2018
Just use the shortcode!
{user:field}
healyhatman 02 Aug, 2018
In where you should put
user_id:{user:id}
GreyHead 02 Aug, 2018
Hi cruser,

It looks as if you are using a different Model name and not 'Article' for your listing.

Bob

PS There are short codes for user info - please check this FAQ
cruser 02 Aug, 2018
Is this what you mean Bob? Or is it another area that I need to change the model name?

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