I'm trying to create filtered views of a master table, so users only see the information relevant to them. They should not be able to unfilter this data to see other people's information.
I added a default filter value of %CURRENT_USER_EMAIL% to an email column, and that works. However, I have to have filtering turned on and visible for this which means that the user can override the filter. Is there a way that the filter can be locked?
Is there a way to create the filter within a shortcode so I can also insert a comprehensive view of the table elsewhere?
Also, the entire table flashes on load before it is filtered--not sure if anything can be done about that.
I'm pretty sure what I'm looking for is possible. I just haven't got my head around it.
Filtering needs to be enabled for it to work, but we would be able to hide that filter with some custom CSS if you can provide me with a URL to the page where the table is.
How is the table created? If it's an SQL query-based table, you can prefilter it through the query, like:
SELECT * FROM yourTable WHERE user_email = %CURRENT_USER_EMAIL%
That way, the table will only display rows based on that condition.
Can you please record your screen, showing me how the table flashes, I couldn't replicate that on my end?
Using CSV as the source can't achieve this, unfortunately. You would need to add a variable placeholder that would change depending on the page.
If the dependency is the user, you can try a workaround. Please note that this does require some experience with writing SQL queries and using WP hooks.
You can create a table with a query like this:
SELECT user_id, user_name, user_address,
CONCAT('<a href="http:/yoursite.com/your_custom_page?user_id=',user_id,'">Details</a>') AS Details
FROM your_table_name
Then, on your_custom_page you will insert a shortcode of the table ID that you need, with a placeholder like this:
[wpdatatable id=1 var1=1]
The second table would be created from a query like this:
SELECT * FROM second_table WHERE user_id = %VAR1%
After that, you can use a hook for dynamic placeholders:
function updateVAR1($tableID){ global $wdtVar1;
//check is set GET parametar user_id
if(isset($_GET['user_id'])){
//get value from form field
$wdtVar1 = $_GET['user_id'];
}
}
add_action('wpdatatables_before_get_table_metadata', 'updateVAR1');
I hope this helps you achieve the results that you need.
As for the flash - the plugin displays the first 10 rows, as it's set in the settings, and then it replaces the filter from the predefined filter and filters the table.
Can you please set up this table, so it only shows one row in the "Display length"?
I'm trying to create filtered views of a master table, so users only see the information relevant to them. They should not be able to unfilter this data to see other people's information.
I added a default filter value of %CURRENT_USER_EMAIL% to an email column, and that works. However, I have to have filtering turned on and visible for this which means that the user can override the filter. Is there a way that the filter can be locked?
Is there a way to create the filter within a shortcode so I can also insert a comprehensive view of the table elsewhere?
Also, the entire table flashes on load before it is filtered--not sure if anything can be done about that.
I'm pretty sure what I'm looking for is possible. I just haven't got my head around it.
Thanks!
Hello Lucas
Thank you for your purchase!
Filtering needs to be enabled for it to work, but we would be able to hide that filter with some custom CSS if you can provide me with a URL to the page where the table is.
How is the table created? If it's an SQL query-based table, you can prefilter it through the query, like:
That way, the table will only display rows based on that condition.
Can you please record your screen, showing me how the table flashes, I couldn't replicate that on my end?
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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
Hi again Lucas
Using CSV as the source can't achieve this, unfortunately. You would need to add a variable placeholder that would change depending on the page.
If the dependency is the user, you can try a workaround. Please note that this does require some experience with writing SQL queries and using WP hooks.
You can create a table with a query like this:
Then, on your_custom_page you will insert a shortcode of the table ID that you need, with a placeholder like this:
[wpdatatable id=1 var1=1]
The second table would be created from a query like this:
After that, you can use a hook for dynamic placeholders:
I hope this helps you achieve the results that you need.
As for the flash - the plugin displays the first 10 rows, as it's set in the settings, and then it replaces the filter from the predefined filter and filters the table.
Can you please set up this table, so it only shows one row in the "Display length"?
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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
Thanks! I'll admit--I'll need to tap into someone more technically astute than me to manage these.
You're welcome, Lucas
I'm sorry that (at the moment) we don't have a simpler solution for this.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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