Okay
  Public Ticket #2805080
wpdatatables serialized php using VAR1
Closed

Comments

  • Noah started the conversation

    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

  • [deleted] replied

    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.


  • Noah replied

    Thanks!  Any help much appreciated, we're on a time crunch.  

  • [deleted] replied

    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

    case 'serialized':

    and under it add this

    $url =  apply_filters('wpdatatables_filter_url_php_array', $tableData->content, $this->_wpId);

    so it looks like this

    7837078816.png

    In hook you will do something like this

    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.