You could specify the meta key in the user query so the results you’re getting back are only for users who have an existing field.
For reference WP_User_Query custom field(user meta) params.
$args = array(
'role' => 'Subscriber',
'meta_query' => array(
array(
'key' => 'old_meta_key_name',
'compare' => 'EXISTS'
)
),
);
$users_with_meta = new WP_User_Query( $args );
$users = $users_with_meta->get_results();
Related Posts:
- How to check if image is already stored in a site’s post database? (network)
- Changing user_nicename
- WordPress will not operate correctly
- How to Join two tables from separate databases within WordPress
- Refresh page after update_post_meta
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Import 10,000 Users into WordPress WITH a specific ID for each user
- WP database error for comments_popup_link()
- if statement on database query
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- How to create Sub Sub domain Multi User blogs?
- How to generate page content from database the right way?
- Proper way to edit a post via phpMyAdmin without breaking the compare revisions tool
- Store and Work with huge array in WP [closed]
- phpMyAdmin displays error when importing database
- Adding Custom Forms
- How to get the POST TITLE using the POST ID?
- Why is the post meta[] empty when I make a call to the wordpress rest api?
- Is it necessary to sanitize wp_set_password user input?
- WordPress Scheduled Event Request Blocking
- Trying to establish connection to External Database
- How to insert a single row to WP database table?
- $wpdb->update with multiple parameters gives error
- wp search-replace on database returns PHP fatal error: Array and string offset access syntax with curly braces is no longer supported
- Is it possible to create a wordpress database with php code?
- Store a default value for a transient on plugin activation
- Seach custom post type posts only by meta fields?
- Split reads to a different connection string
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- inserting a post from an extern php file but post content doesn’t show on wp site
- Not connecting to database in file with multiple MySQL connections
- WordPress Block developer from exporting Database via PHP
- Execute a function every hour in the background
- How do I display offsite database info on my wordpress site?
- How to use array in function to get only value I want
- Building a REST API for your web app exposes primary keys of DB records?
- How to update and save user metadata on page visits?
- Most commented posts by time period (last 12h, last 24h and etc)
- Saving data from custom form in wordpress database
- wpdb Cannot Update column in Database
- Set default Database Storage Engine when creating tables with plugins?
- Get wp_current_user_id using PHP and MySQL
- WPDB – Read and write value from / to database
- How do I make this Metabox show current DB value?
- How to Generate a list of Most Commented post?
- Why when I create a new post I found 2 record related to this post into the posts database table?
- Adding data to custom wordpress database table
- select a single val though a table in wordpress
- Unserialize Custom Field & Save as Multiple Rows in WordPress Database
- Add posts to custom table in database instead of wp_posts
- What’s wrong in my PHP code? I’m using WordPress Astra Theme and I can’t insert data into my SQL
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- $_POST returning empty values
- How to send custom form submissions to WordPress Database?
- Submiting with problems on one of the options php wprdpress
- wp_update_post gives 500 internal error
- Confuse between forms and tables
- code that I can run, or a plug in to show what sql tables something pulls information from
- Adding column to wpex_users
- Using wpdb to connect to a different database is not working
- Editing the term_order field
- WordPress database error only while loading page for 1st time
- Multiple WordPress sites with different theme and plugin sharing the same content
- How to grab data from input and store it into custom table in database?
- custom search query database in child theme
- Insert data from form to database
- How do I fetch a data from an external database into my wordpress homepage
- Full search and replace isn’t enough to make all pictures to be loaded with https
- Generate random access token to a post page
- How to query a staging database?
- Get meta_query value by user meta array
- 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?
- Child theme functions.php file change database entries
- Display Content Based on Custom Field Value
- Can form entries from a WordPress form go to a database
- Weird Behaviour: Not all WordPress Posts appearing
- Can not manually create a database ( db, user, pass ) for a plugin
- two wordpress sites, two themes, one database, same content
- Insert double entry in DB
- Manipulate database of WordPress site with my own scripts
- Check if values exists DB
- MySQL database migration to WordPress
- Host does not allow remote connection, so how do I transfer data to my WordPress site?
- MySQL Engine vs. Charset
- Custom query_posts() parameter
- How to print array of specific item
- How to check if a value exists in one of two database tables
- How to pass username into form that sends data to database
- How to edit the default database of WordPress [closed]
- notify users when changed database
- Display total count of products in orders of a specific order status
- save array of objects with update_option
- Execute multiple PHP Snippets causes error?
- Search custom post type posts only by meta fields?
- Bulk data save in custom table
- Can’t insert into a database wordpress
- WordPress Insert line in DB when clicking a button
- Updates applied to staging WordPress site affecting production even with different databases