I need the flexibility of the php serialized array based table so that I can include dynamic columns, but in order to make the correct mysql database call in my php script I need to be able to pass url parameters to the script. Since wpdatatables is making a cURL call to the parser, I can't use $_GET, so instead I'm using some script on the plugin side to add the url parameter to VAR1 in the wpdatatables shortcode.
My question is how to receive the VAR1 value in my php script that's producing the serialized array. Any help much appreciated!
function test ($url,$id) {
// all data from current user
// you can fetch only what you need
$userData = wp_get_current_user()->data; if(isset($userData)){ $url .= '?' . http_build_query($userData); }
return $url;
}
add_filter('wpdatatables_filter_url_php_array', 'test', 2 , 10
In the PHP file, you will use $_GET method to take the values from the URL which is filtered with the hook
// you can check then for ID or user_login or user_pass or user_nicename or user_email ...
if(isset($_GET['user_login'])){ //do somthing
}
Do let us know if you need any further assistance.
Hello,
I need the flexibility of the php serialized array based table so that I can include dynamic columns, but in order to make the correct mysql database call in my php script I need to be able to pass url parameters to the script. Since wpdatatables is making a cURL call to the parser, I can't use $_GET, so instead I'm using some script on the plugin side to add the url parameter to VAR1 in the wpdatatables shortcode.
My question is how to receive the VAR1 value in my php script that's producing the serialized array. Any help much appreciated!
Best,
Noah
Hi Noah
Thank you for reaching out to us.
I have forwarded this to our developers as they will be able to provide a more accurate answer. I will update you as soon as I hear back from them.
We appreciate your time and patience.
Thanks! Any help much appreciated, we're on a time crunch.
Hi Noah
Thank you for your patience, we really appreciate it.
You need to add one more hook to filter that URL of PHP file.
In file wp-content/plugins/wpdatatables/source/class.wpdatatable.php: around line 1875
you will find this
and under it add this
so it looks like this
In hook you will do something like this
In the PHP file, you will use $_GET method to take the values from the URL which is filtered with the hook
Do let us know if you need any further assistance.