For my WordPress site, I would like to echo the value of a column in a row (determined by the user’s ID) of a table in the database for my site. This table was created by a plugin so it is not accessible through the user meta. I have to try and get the value from the table created by the plugin.
For this example, the value is located in the “plugintable” table in the database and the column is “columnname”. How get I get the value based on matching the user’s ID with the “ID” row?
I’ve gotten here from the help of other online sources, but I’m stuck.
<?php
global $wpdb, $table_prefix;
$user_ID = get_current_user_id();
$value = $wpdb->get_var('SELECT columnname FROM '.$table_prefix.'plugintable WHERE ID = '.$user_ID);
echo $value;
?>