OK, so first of all, you should always use proper escaping, when building the queries.
This is how your code can look after fixing:
global $wpdb;
$value = $wpdb->get_var( $wpdb->prepare(
" SELECT column_name FROM {$wpdb->prefix}plugin_table WHERE ID = %d ",
get_current_user_id()
) );
The things you have to take care of:
- You have to change
column_nameto proper column name you want to get. - You have to change
plugin_tableto proper table name you want to get the value from. - You have to change
IDto proper name of column that stores the user id in given table.
Related Posts:
- Querying multiple meta_keys in WordPress SQL query
- How to return number of found rows from SELECT query
- $wpdb->get_results(…) returns empty array despite correct query
- $wpdb->delete column values IN ARRAY()?
- Display data from a non wordpress database on a page template
- How to auto login user again after change user_login
- How to Join two tables from separate databases within WordPress
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- How to generate page content from database the right way?
- phpMyAdmin displays error when importing database
- Get stock by custom meta field on all Woocommerce variable products
- Any possible way to make $wpdb->get_results() return anything else than array?
- database interactions using OOP
- Transferring working local PHP site to wordpress – with database (MySQL)
- how to delete 30 day old data using PHP [closed]
- Display fields as values in array from external SQL DB
- Trying to establish connection to External Database
- Getting id of poll from WP database
- How to insert a single row to WP database table?
- $wpdb->update with multiple parameters gives error
- Querying wpdb using PHP
- Update results, Before deleting the related category [closed]
- How WordPress reacts to a lack of memory of the server [closed]
- $wpdb->insert() does not Insert record in a table
- Databases – Submitting data from inputs to database [closed]
- Is it best to avoid using $wpdb for security issues?
- How to retrieve the data from the sever and displaying it in a page?
- Use $wpdb or other PHP script method to find/replace in WP database
- How can I add a new row in a separate database when someone registers via WordPress?
- I can’t update my data through $wpdb
- wpdb Cannot Update column in Database
- PHP -> SQL Query with Summing
- Lost in trying to create user database system
- Delete database record using plugin from admin panel
- Wpdb get->results to out the the month from the db
- Filter results from a serialized string to use on statistics
- wordpress site – using custom database and PHP
- WPDB – Read and write value from / to database
- Why my query does not run with prepare
- How to Generate a list of Most Commented post?
- wpdb getting avatars and author url
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- WordPress SQL JOIN query
- Fetching review value using wpdb class
- Add posts to custom table in database instead of wp_posts
- Database SQL query error
- WordPress SQL Prepare
- add role on WordPress in PHP on a second database
- Creating multiple tables with Plugin
- Using wpdb to connect to a different database is not working
- How to grab data from input and store it into custom table in database?
- Front end/Database connection in WP
- direct query to post_meta table
- can’t delete a row from post_meta table
- Accessing external database: ERR_INCOMPLETE_CHUNKED_ENCODING
- Can not manually create a database ( db, user, pass ) for a plugin
- How to fetch results from database
- MySQL database migration to WordPress
- Fetching wpdb data from a php file seems to break?
- Insert into db with foreach problem
- Can’t send form data to wpdb when URL has query string
- How to get data (not value or name) from radio options to POST to database
- Retrieve data from external database and insert back in
- Putting form result in my database
- Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- WPDB Insert or if exists Update
- How to check if image is already stored in a site’s post database? (network)
- How to get the list of WooCommerce product image of a certain category from database?
- Changing user_nicename
- PHP syntax error when using wpdb update?
- my function doesn’t return my post from today
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- wpdb_prepare with multiple or condition
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- SQL QUERY – Select a value directly from the database
- I want to select the from values from database in WordPress? [closed]
- How does WordPress know wich language is chosen when there is a database connection error
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Not connecting to database in file with multiple MySQL connections
- How do I prepare strings for insertions as values into a MySQL table?
- Why won’t this wpdb get_results query return results?
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- Confuse between forms and tables
- code that I can run, or a plug in to show what sql tables something pulls information from
- Looping through custom data in a custom table to display all items in a post
- I changed the password for the database user of my website, updated wp-config.php and wordpress asks to be reinstalled
- I want to use wordpress database in android app using json encode?
- Include post_status check within $wpdb query
- Run insert if no entry otherwise run update with ajax
- Host does not allow remote connection, so how do I transfer data to my WordPress site?
- MySQL Engine vs. Charset
- How to check if a value exists in one of two database tables
- Display total count of products in orders of a specific order status
- WordPress Query -> Ajax Query
- how to display tables via ajax
- save array of objects with update_option
- How to sort search result by post_title, then by post_content
- WordPress / PHP: Check if column has value and then check if value in array
- Can’t insert into a database wordpress