Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter khaihong

    (@khaihong)

    I finally figured out that $user_id returns a numeric value, so it was necessary to make use of the add_filter function to get user_login instead. I hope the following helps someone:

    WPTables query:
    select userid, field2, field3 from mytable where userid = $user_login

    functions.php:
    add_filter(‘wptables_mysql_query’, ‘my_custom_query’);
    function my_custom_query($query) {
    $current_user = wp_get_current_user();
    $user_login = ‘\”.$current_user->user_login.’\”;
    return str_replace(‘$user_login’, $user_login, $query);
    }

    Now the table shows data that is specific to the logged in user.

Viewing 1 replies (of 1 total)