I have knowledge in any of the languages used for web development and sql. I am working on a my-customer-pages for a customer. The customer have bought wpDataTables for that purpose.
As a backend I have developed some php-files. I have logged in customer as a variable in php to use where ever. Customer logins have nothing to do with wordpress users.
My query in wpDataTables looks like this right now: select * tblInloggFunktion where Kundnr = %VAR1%
I also have a WP shortcode [MittKundnr] that is correct number for %VAR1%.
Now, my question is how do I dynamically change the query in wpDataTables so that the value I have in either php or the shortcode is used?
How would you solve this? Any input is appreciated, thank you.
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.
-
We don't have this built-in yet, but you can with 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 parameter 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.
It does look pretty neat, so if it works, you can use that as well. The code I shared is for dynamically changing the user ID per a hook for the placeholders. Your snippet seems to do the same thing, so it does look like it should work. Have you tested this?
HI
I have knowledge in any of the languages used for web development and sql. I am working on a my-customer-pages for a customer. The customer have bought wpDataTables for that purpose.
As a backend I have developed some php-files. I have logged in customer as a variable in php to use where ever. Customer logins have nothing to do with wordpress users.
My query in wpDataTables looks like this right now:
select * tblInloggFunktion where Kundnr = %VAR1%
I also have a WP shortcode [MittKundnr] that is correct number for %VAR1%.
Now, my question is how do I dynamically change the query in wpDataTables so that the value I have in either php or the shortcode is used?
How would you solve this? Any input is appreciated, thank you.
Hello.
This is a payed license I use. I was expecting to get any response at all in two days. Come on and give me some response at all.
I also have https://wordpress.org/plugins/code-snippets/ installed to be able to write code.
Regards Mattias
Hello , Mattias
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.
-
We don't have this built-in yet, but you can with 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.
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
Hi.
Thanks for replying. I will look into that since it may be a better solution than the one I came up with, or what do you think?
I found out that your shortcode "wpdatatable" points to a function "wdtWpDataTableShortcodeHandler" and came up with a snippet like this:
<?php
add_shortcode( 'my_profile_edit', function () {
return wdtWpDataTableShortcodeHandler(array('id' => 1, 'table_view' => 'regular', 'var1' => $_SESSION["Nr"]));
} );
?>
This triggers the same function and sets the var1 to the value I want. I just add [my_profile_edit] as a shortcode in wpress where I want the table.
Regards Mattias
Hi, Matties
It does look pretty neat, so if it works, you can use that as well. The code I shared is for dynamically changing the user ID per a hook for the placeholders. Your snippet seems to do the same thing, so it does look like it should work. Have you tested this?
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
Yes, it works :-) At least as long as you guys don't change the name of the function associated with the shortcode.
Regards Mattias
Hi, Mattias
That is awesome! I don't believe we will be changing the name of the function, so should be good to go.
We are delighted to see that it works, of course.
- If anything else happens, please don't hesitate to create new tickets. Have a nice day!
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