Without a proper SQL query in the question is not possible to write a proper query in the response, but following your pseudo-code approach:
SELECT custom-data
FROM custom-table
LEFT JOIN wp_users ON custom_data.user_id = wp_users.ID
LEFT JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id
WHERE some-condition
AND wp_usermeta.meta_key = 'flag'
AND wp_usermeta.meta_value="flagvalue"
So basically, you need to join against wp_usermeta, which is where you’d be storing your users “flag”.
Related Posts:
- Insert, update or remove data from database (usermeta)
- Should I use wpdb prepare?
- Getting wrong relationship value in $args in wp_Query?
- Does using set_transient() function can lead to MySQL problems?
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- How is the data stored in the database?
- Add new user and add meta at once
- How to add quick edit and bulk edit fields to users admin section
- What is rich_editing?
- How can I free up the memory used by update_post_meta?
- Passing array of strings to a SQL statement in a WordPress plugin
- Activation hook not creating table
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- How to edit mySQL wp_posts table from plugin php?
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- $wpdb -> Batch insert from XML File?
- query users by role
- Ensure function has completed before allowing another Ajax call
- WordPress database error for query INSERT INTO
- How to connect to AWS RDS external database (not for the core WordPress db)
- How to add custom fields to the all users page
- WordPress allows multiple users to have same email ID; and I’ve a problem with it!
- How to add user details to different tables immediately after user registration
- mysql_real_escape_string() vs. esc_sql() in WordPress
- How to get all queries’s results after they have executed?
- How to build a fool proof AdSense revenue sharing model?
- How to pull user/author profile data in a plugin?
- How can I add a simple custom field to my plugin?
- $wpdb->prepare with LIKE and sprintf
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Associate multiple email addresses with the same user account, so they can log in with either
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Using AND and bracket grouping in SQL not working
- Change/Set Page Title and Meta Tags from Page Called within a Plugin
- Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
- Update a user profile via frontend
- How can I programmatically change a MySql variable (foreign_keys_check)?
- Auto-complete or auto-suggest from stored data in database
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- $wpdb->prepare is not working like mysql_real_escape_string
- Brainstorm – Slow Query from Plugin Need to Speed It Up
- Create an user on external database
- What could cause a WP Option to get truncated?
- How to relate the Category to user?
- WordPress database error: [Query was empty] – using $wpdb->prepare()
- Foreign wp_users ID in custom plugin DB table?
- How to Get Last ID?
- Catching a GET parameter from the URL and save it in the user meta when a user registers
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- User meta query using Wildcard
- Is it possible to replace MySQL with JSON files for WordPress
- User avatar-ACF fields
- WordPress doesn’t create table on plugin activation
- WordPress delete mysql rows with string
- Organising and completing posts (mark as read and hide)
- WordPress function is not called and ajax return 0
- pull data from wordpress database
- sql query not working in wp plugin
- $wpdb Mysql trigger problem
- Custom MySQL query to pull out Advanced Custom Fields?
- How to filter get_adjacent_post()?
- $wpdb how can i save my postmeta table before querying it
- How to work with AJAX and WordPress?
- Nothing happens on WordPress Update command
- Create Unique and Customized User ID for Website Members in WordPress
- How to get custom user meta by id in custom Gutenberg block
- Custom frontend page for plugin without a ‘physical’ page?
- Using AJAX in a plugin to submit form – REALLY confused
- Plugin Architecture/Design Pattern – is better to use a private Observer/Mediator Pattern for plugin subclasses or WP add_action?
- Post added via wp_insert_post with category doesn’t show in category listing
- How to add more than 1 user role to sub-menu pages
- How to properly use a hook to create template for custom product type in a plugin such as Woocommerce? [closed]
- Using a front controller in a WordPress plugin, any suggestions?
- Self-hosted plugin update problems
- Save image as featured image
- Best choice of options/settings framework for plugin/theme development
- Hide plugin dashboard menu item for specific roles
- How to use relative path with my plugins folders?
- conditionally load javascript & CSS for do_action() calls from plugin
- Create custom HTML/JS app inside page
- Plugin Development for registered users
- tinymce.get() returns error after ajax request
- Upload multiple images and insert them into custom html code
- Using OOP inside a Plugin – Is it allowed?
- How to grab query string from wp-content/uploads/.*
- Configure WordPress to Generate Scheme-less Relative URLs
- WordPress templating system for custom plugins
- Lead form that submits to 2 external APIs
- Modify code for functions.php with specific twitter user url and hashtags
- Add new header/footer on landing page with plugin
- Redirect with message after admin_post.php
- How should I use wpdb class to submit a form in admin dashboard?
- Forcing ALL plugin Admin menus into a separate menu
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- register_activation_hook doesn’t execute without add_action(‘init’,’some-function’)