How can I have different roles to access different parts of the table. Not everyone who can see/edit data in the table must have rights to see/edit everything in it. I really don't want to split up the tables/database into parts. I want to use just one database/table for being able to make complete reports.
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
-
Just when you say 'different parts of the table' i am not sure if you mean columns or rows.
1. If you mean to have some Columns load for User with Role A, and some other Columns show for user Role B; something like that is not currently possible.
We don't have a built-in solution for this (yet); our developers with be working on adding it in the future, but i can't say an ETA on it, though.
to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there, and as more people vote, the feature will move higher on the priority list.
You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;
and our newsletter, so you're informed about new features, bug fixes, freebies, etc.
At this moment, unfortunately, we can't create a solution as intended, in terms of one dynamic table having columns that can hide or show depending on a user role.
- The solution we can suggest for this functionality, is creating multiple tables on multiple pages.
You can have one main "source table" that holds all the data and columns.
It could be a Manual type, or SQL based (has to be created in the database), and then create separate tables from it by an SQL Query, each query can pull only the columns you need for a certain role. (an Admin can have access to the main/source table).
;
- In order to limit access to certain pages and tables, since wpDataTables can't do that, you can install a membership plugin, and set up which roles are restricted/allowed to view certain pages.
So, for example, if table 1 is for the Subscriber role, limit that page just for them, a second table just for editors, and so on; depending on what you need to achieve, which you can set up with a membership plugin.
- I hope that helps.
2. But if you mean to filter which rows are shown per User Role, there can be a Custom workaround with an SQL Query :
We don't have an easy built-in feature to achieve filtering per user role,
but there is a custom workaround that we can suggest.
You could add custom user roles, through the Membership, and here is an example of a table.
If the dependency is a user role, for example, we could make it work.
If I have this table:
This is a manual table which has manually entered IDs from wp_users and roles from wp_usermeta:
So, then I go to create an SQL query based table which will display entries based on user roles using this query:
SELECT new_table.id AS ID,
new_table.role AS Role,
new_table.product AS Product,
new_table.amount AS Amount
FROM wp_wpdatatable_6 AS new_table
JOIN wp_usermeta AS new_table_1
ON new_table_1.user_id = %CURRENT_USER_ID%
AND new_table_1.meta_value LIKE CONCAT('%', new_table.role, '%')
When I'm logged in with user ID = 1, I see this:
When I'm logged in with user ID = 4, I see the same thing. And when I'm logged in as one of the subscribers, I can only see the rows where role = subscriber:
The only difference is that as subscriber I don't have access to back-end, so this confirms it is working on both front and back.
So, we're only left with hiding unnecessary columns, adding names, and so on.
Thank you. As a workaround I did the membership/Queries/Pages trick. It works for the selection, but even with only subscriber rights it keeps on being possible to edit en save rows in the query. Which of course I don't want.
Yes. When it comes to separating who can "see" and who can "Edit" the rows;
with out built-in features, you can only try using the Editor Roles on a Table.
As we pointed out in this Documentation, this option from the “Editing tab” where you can set only specific user roles to be able to edit the table, choose in this dropdown.
If you use some custom roles from other plugins (like it is S2Member, User Role Editor or any other), those roles will be available here.
If you leave that unchecked, then it will allow editing for everyone.
So, if you have one or more specific User Roles, so only they can be allowed to edit the Table, then add these Roles to the Editor Roles - in that case, if any other User Role visits the Table, they will not be able to edit it.
How can I have different roles to access different parts of the table. Not everyone who can see/edit data in the table must have rights to see/edit everything in it. I really don't want to split up the tables/database into parts. I want to use just one database/table for being able to make complete reports.
Hello;
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
-
Just when you say 'different parts of the table' i am not sure if you mean columns or rows.
1. If you mean to have some Columns load for User with Role A, and some other Columns show for user Role B; something like that is not currently possible.
We don't have a built-in solution for this (yet); our developers with be working on adding it in the future, but i can't say an ETA on it, though.
You can affect the development speed. Please feel free to search on our suggestions page,
to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there, and as more people vote, the feature will move higher on the priority list.
You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;
and our newsletter, so you're informed about new features, bug fixes, freebies, etc.
At this moment, unfortunately, we can't create a solution as intended, in terms of one dynamic table having columns that can hide or show depending on a user role.
- The solution we can suggest for this functionality, is creating multiple tables on multiple pages.
You can have one main "source table" that holds all the data and columns.
It could be a Manual type, or SQL based (has to be created in the database), and then create separate tables from it by an SQL Query, each query can pull only the columns you need for a certain role. (an Admin can have access to the main/source table).
;
- In order to limit access to certain pages and tables, since wpDataTables can't do that, you can install a membership plugin, and set up which roles are restricted/allowed to view certain pages.
So, for example, if table 1 is for the Subscriber role, limit that page just for them, a second table just for editors, and so on; depending on what you need to achieve, which you can set up with a membership plugin.
- I hope that helps.
2. But if you mean to filter which rows are shown per User Role, there can be a Custom workaround with an SQL Query :
We don't have an easy built-in feature to achieve filtering per user role,
but there is a custom workaround that we can suggest.
You could add custom user roles, through the Membership, and here is an example of a table.
If the dependency is a user role, for example, we could make it work.
If I have this table:
This is a manual table which has manually entered IDs from wp_users and roles from wp_usermeta:
So, then I go to create an SQL query based table which will display entries based on user roles using this query:
When I'm logged in with user ID = 1, I see this:
When I'm logged in with user ID = 4, I see the same thing. And when I'm logged in as one of the subscribers, I can only see the rows where role = subscriber:
The only difference is that as subscriber I don't have access to back-end, so this confirms it is working on both front and back.
So, we're only left with hiding unnecessary columns, adding names, and so on.
Hope this helps.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Thank you. As a workaround I did the membership/Queries/Pages trick. It works for the selection, but even with only subscriber rights it keeps on being possible to edit en save rows in the query. Which of course I don't want.
Hello;
My apologies once again for all the waiting time.
Yes. When it comes to separating who can "see" and who can "Edit" the rows;
with out built-in features, you can only try using the Editor Roles on a Table.
As we pointed out in this Documentation, this option from the “Editing tab” where you can set only specific user roles to be able to edit the table, choose in this dropdown.
If you use some custom roles from other plugins (like it is S2Member, User Role Editor or any other), those roles will be available here.
If you leave that unchecked, then it will allow editing for everyone.
So, if you have one or more specific User Roles, so only they can be allowed to edit the Table, then add these Roles to the Editor Roles - in that case, if any other User Role visits the Table, they will not be able to edit it.
I hope that helps.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables