It looks like you're new here. If you want to get involved, click one of these buttons!
Hi all, I have extend existing Users module and add one extra field to it, for example City. I have 5 users with different City entered and would like to limit all Simple Modules data by that criteria (City).
Simple Module will pull data from table and column City should be way to limit access for users to see only data they are assigned to.
How can I bind and filter data on that way?
Thanks
Comments
The Base_module_model (which the models extend from) has a property on it called
$limit_to_user_field
which you can be used to specify a field name (e.g. user_id) that will limit what is displayed in FUEL. This field is used in theBase_module_model::_limit_to_user()
andBase_module_model::_editable_by_user()
methods if you are curious as to what it is doing under the hood.So in your case, in your model that you extended add the property:
public $limit_to_user_field = 'my_user_field_id';
Wow this was quick! I am not sure how to implement it in my case. This 'my_user_field_id' represents field I have set in simple module mysql table. I am wondering if I want add multiple users to access same data (2-3 users from same city), I would not be able to limit by ID as you described. I am planning to make advanced module but Simple Module is starting point.
This is something I am planning to use for representing data as charts etc https://www.koolreport.com/ I am not sure if FUEL has any ability to use charts instead of list View.
I will try now this what you suggested and thanks a lot for quick reply.
Quick reply; I've tested what you suggested and it works. Admin can see everything and regular user has limits on data by it's user_id. It is quiet simple to use