Yes, I think your quotes after the WHERE are backwards. Try it like this:
...$fields.' WHERE wp_users.ID='.$current_user->ID );
The “WHERE wp_users.ID=” part is plain text that is intended to be part of the query, so it needs to be in quotes. The $current_user->ID is a variable that should live outside the quotes.
If that doesn’t work, I would suggest using a variable to store the SQL query and then output it as debugging. That way you can see what is being formed and see if it is what you expect.
This is how I do it:
$sql = db->prepare( "SELECT * FROM $table WHERE user=%s", $current_user->ID );
Hope this helps!
BTW, it took me awhile to get used to using a period as a concatenation operator.
Related Posts:
- How to make WordPress plugin check for database changes and then do something?
- Database “Migration” for Plugins?
- See output of a sql query while plugin installation in wordpress
- When to use Exceptions vs Error Objects vs just plain false/null
- WordPress URL Rewrite not working
- Detect a focus on wp_editor
- How to Join two tables from separate databases within WordPress
- simple wordpress ajax plugin not working when not logged in
- Utilize WP-CLI from inside WordPress, not SSH
- Saving metabox repeatable fields
- how to create and show sessions in word press?
- do not show web page section when using advanced custom fields pro
- How to get all existing post types
- New Plugin Review
- Create custom blocks for bootstrap
- allow users to publish without admin approval
- register_activation_hook isn’t adding table to DB
- How to generate page content from database the right way?
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Do my defines need to be unique?
- phpMyAdmin displays error when importing database
- Preferred Method of debugging a wordpress SQL calls?
- WordPress Scheduled Event Request Blocking
- Delete a WordPress transient from a shortcode on Page/Post update
- Importing Geo data into wordpress database
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Saving an array of dynamic repeater data as post_meta
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- Improve page speed loading using CDN and async or defer attribute
- Script to browser problem PHP
- Store a default value for a transient on plugin activation
- wp query foreach deleting record returning only first or last item
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- WordPress Custom field Colors
- What exactly do this function declared into functions.php file of a WP theme?
- How to use html inside a functions.php code?
- WordPress Environment: Dynamic Page using shortcode – how to change the page name for sharing
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- plugin add action hook is not working :
- Is it save to use eval for a jQuery callback method coming from the database?
- zip unzip attachments in wordpress
- wordpress admin plugin menu custom css
- How to Update post_modified of all wordpress post
- how to Update 15k products on plugin activation with meta_option
- Lost in trying to create user database system
- Hooks for post saving make a post-new.php to load latest post’s data
- Adding Additional Variables on Menus Page
- Using flickr api in custom wordpress plugin
- Toolbar Hidden in a Virtual Page
- making php value numeric
- Using color schemes with Color Picker
- PHP: $_SESSION destroyed after page reload for my custom session
- How to use wp_send_json() and output the value with ajax?
- How to correctly escape an echo
- Payment field disappears on custom Paypal plugin
- Adding image upload in tag section – WordPress plugin development
- How to detect and handle the time difference between server and user in WordPress?
- How to Remove Theme Style CSS inside Custom Plugin?
- How to setup the Email piping in WordPress plugin?
- get different meta-data of a complicated query at the same time
- Build A Custom SQL Query for WordPress Search
- How to run complex query using PHP
- Creating plugin with front-end pages
- Storing huge number of users in wordpress
- How to Send Pingbacks for all Posts in WordPress?
- I am having errors with checkout on wordpress
- Getting an error when my plugin is updated, but the files update correctly
- Creating multiple tables with Plugin
- Custom User registration system
- How to use Multi SQL Database in WordPress?
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- 400 bad request admin-ajax file upload
- get Woocommerce product format json for WP_Query
- Update user meta when an external link in admin notice is clicked
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- The plugin generated 225 characters of unexpected output during activation
- Ajax in a class instantiated via shortcode
- Parsing webhook from Shopify in WordPress
- Shortcode Works for Logged in Users but Not Working for Guest
- Unable to pass variable to database
- Gravity Forms Marketo Plugin Feed [closed]
- Add custom filter to register data in array
- How can I order metaboxes in my posts in WordPress?
- Trouble using wordpress functions in a pop-up modal form
- MySQL update text field with ‘
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- display php code in header using wp_head()
- How to pass and validate nonce in custom REST routes
- Can’t send form data to wpdb when URL has query string
- ajax problems on loading page [closed]
- How to sort search result by post_title, then by post_content
- wp_mail – send emails after 24 hours from users registration
- Compare user meta values before update them
- Capture the Selected Radio Button Value between two files in wordpress theme
- How to change product SKU’s in bulk with a plugin
- JQuery UI Autocomplete showing as bullets
- Add Imports to Existing WordPress Import Map
- Custom plugin with dynamic child pages listing database records