So I know you can display db data based on an sql query, but is there a way to make this query different depending on what user views it?
For example, say I have a table set up for shop items. If a user of shop1 views the page the sql query should be for the table shop1 but if user of shop2 views it it should be different items?
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.
-
Sorry to disappoint you, we do not have any built-in way to achieve what you described.
At the Back-End of the Table, you need to have a working Query in order for our Plugin to initially generate the Table.
But i will share a custom workaround idea, so if you have coding skills you could try a custom solution.
This is how you can make a dynamic SQL Query for the Front-End, which can change the Query according to a variable sent from an API or PHP.
You can use this hookwpdatatables_filter_formdata_before_save
//$formData array of entries from edit modal
// $tableID table id int
function updateValuesBeforeSave($formData,$tableID){
//for specific table id
if ($tableID == 1) {
//Your logic to send data to API URL from for example column that have orig_header col_1
// you will use $formData['col_1']
// then response from your API URL you will insert on anoter column that you need for example if column is
// called col_2 then you will insert response of that API like this
// $formData['col_1'] =
//response from your API URL
// then that data will be saved in database and also shown in your table on front } return $formData;
}
add_filter('wpdatatables_filter_formdata_before_save','updateValuesBeforeSave', 10, 2);
I hope that will help you.
Just wanted to point, these are custom solutions, which are not included as part of our support. Even though we always give extra effort to give examples, if we have any for certain situations.
Please note that using hooks requires certain level of programming skills and included support refers only to advice.
So I know you can display db data based on an sql query, but is there a way to make this query different depending on what user views it?
For example, say I have a table set up for shop items. If a user of shop1 views the page the sql query should be for the table shop1 but if user of shop2 views it it should be different items?
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.
-
Sorry to disappoint you, we do not have any built-in way to achieve what you described.
At the Back-End of the Table, you need to have a working Query in order for our Plugin to initially generate the Table.
But i will share a custom workaround idea, so if you have coding skills you could try a custom solution.
This is how you can make a dynamic SQL Query for the Front-End, which can change the Query according to a variable sent from an API or PHP.
You can use this hook wpdatatables_filter_formdata_before_save
I hope that will help you.
Just wanted to point, these are custom solutions, which are not included as part of our support. Even though we always give extra effort to give examples, if we have any for certain situations.
Please note that using hooks requires certain level of programming skills and included support refers only to advice.
Thank you.
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