Forums

owner id as a var

emmexx 23 Nov, 2017
I don't understand how to use the owner id field with a variable.

I want to let only the user that created a record, edit it.
In the edit event / Permission owner id field I tried to put a function or a var that should retrieve the user_id from the table. But how can I put "something" that returns a value in that field if there's no function that can do that in CC6 (to my knowledge).

I created a php function that retrieves the user_id of a record and returns the value but:

{fn:get_user_id} doesn't work
{var:get_user_id} doesn't work
{fn:get_user_id}{var:get_user_id}

The function works in other contexts (if I put {fn:get_user_id}{var:get_user_id} in the content field of the event I get the user_id).

What is the right way to accomplish that?

Thank you
maxx
Max_admin 29 Nov, 2017
Hi maxx,

In the "owner id value" field you need to provide the value of the record owner which is going to be matched against the value of the logged in user id, so if you are trying to apply this in an "edit record" form then you could use {var:read_data.model.user_id_field_name} in the "owner id value"

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
emmexx 29 Nov, 2017


In the "owner id value" field you need to provide the value of the record owner which is going to be matched against the value of the logged in user id, so if you are trying to apply this in an "edit record" form then you could use {var:read_data.model.user_id_field_name} in the "owner id value"


That's what I did but probably I used a wrong syntax.
I had to put the user id in the url and used {data:user_id} in owner id value.
I'll try again.

Thank you
maxx
Max_admin 29 Nov, 2017
Answer
Hi maxx,

If this is an "event" then it may not work because the event permissions are checked before the functions inside the event are processed, the "read_data" data would only be available to a function or view after the "read_data"

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.