Use this code instead-
$args = array(
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC'
);
$users = get_users( $args );
foreach ( $users as $user ) {
$user_id = $user->ID;
$post_count = count_user_posts( $user_id );
if ( $post_count > 0 ) {
$user_meta = get_user_meta( $user_id, '', true );
echo 'ID: ' . $user_id . ' | ';
var_dump( $user_meta );
echo '<br />';
}
}
Ensure the get_user_meta
function retrieves all meta keys by passing an empty string as the meta key and setting the third parameter to true
to return the data in a single array.
Related Posts:
- how to get list of all users and their metadata
- Check if WP_User_Query ‘include’ is empty
- get_users / WP_User_Query returns empty when logged out
- Showing all users who match 2 meta fields with current user
- Why get_users() not working on the admin backend?
- WP_User_Query not returning users with meta – what am I missing?
- Randomize Users
- How do I sort a WP_USER_QUERY by multiple meta fields?
- Wrong result in fetching User meta of WordPress
- How to make a custom column on the Users admin screen sortable?
- Query users by custom taxonomy and user role
- wp_update_user doesn’t update and update_user_meta does
- remove user_meta data from database for all users
- How to get last login Access Date and time
- Getting all user metadata from user
- How to get user metadata for social media url?
- Admin user edit – Grab newly submitted user meta immediately after update/submit
- Wp_User_Query not sorting by meta key
- wp_get_current_user in custom file returns 0
- Is there a limit to the length/size of serialized data that can be stored as user meta?
- Are the default entries for a user in wp_usermeta documented?
- User Relationship
- What is the meta-box-order_post_hash used for?
- Allow role to edit users at lower level with only specific metadata
- User meta conventions / name registry, for social media links
- Sanitize textarea instead of input
- Multiple User-Meta Values in One User-Meta Key
- Gravity Custom Merge Tags [closed]
- How to insert new element to existing array in usermeta?
- Update user meta through a front end form
- What is the difference between get_the_author_meta() and get_user_meta()?
- Can I prevent “wp_user_level” from getting added to wp_usermeta on registration?
- Get the Google+ and Twitter links – WordPress SEO plugin
- Adding current user’s ID to the end of PDF hyperlinks in post content
- Send mail to user only once when specific check box is selected and updated from profile meta updated by admin
- add custom field in user register form
- Is it possible to read a result if wp_update_user or update_user_meta fails?
- Parent User and Child User – relate users
- User last login and user last visit problem
- Can I set user meta for theoretical user 0?
- Is there a way to append meta data without creating a race condition?
- I want to update my user meta table
- Subscribers Group User meta delete
- Display and Update User Custom Meta via user-edit.php
- WordPress REST API and User meta data
- How do I add a dropdown list of numbers 1 – 1000 as an extra profile field?
- Get user meta for only the keys with a certain prefix
- Serializing User Role for update_user_meta
- Fetch user related data
- How to combine two get_users() array?
- Displaying field value in new column in users view on wordpress
- add_user_meta allows multiple clicks and inserts more than 1 value
- Add user meta fields on creating the user
- Order By Meta_key but convert custom date to Y-m-d first
- Reduce number of SQL queries inside WP_Query loop to fetch author data
- last_name + first_name orderby with meta_query [solved]
- Combining wp_list_authors with get_user_meta
- How to order users by a date in the meta_value array
- Should I have a single cron job that loops the users, or one for each user?
- Updating user meta on save post
- Save editor’s value in user meta and retrieve it
- Exclude specific user_id from args in get_comments
- WP_Editor not saving data in user_meta
- Display Country Flag in Profile WordPress/Buddypress
- gform_after_submission not working as expected [closed]
- Combining two meta_values within one row with query
- Remove user id’s stored in arrays that themselves are stored in user meta of another user
- Fetch user’s using Last Name
- How to get metadata (in my case mail) of users who have a certain set of metadata?
- How can I search user meta by a partial key name?
- user metadata in json format, update the data partly only
- get_user_meta value is stored within strange characters
- check metadata in wordpress
- wp_redirect not working after update_user_meta
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- profile_update works on second update only
- How to remove the url format from the WEBSITE field in the user registry?
- users joined group count in buddypress
- Get user count based on multiple meta key values?
- SQL – Shorter way to query user and usermeta data
- WP author meta disappeared
- get_the_author_meta i want to write in a loop
- How can I track who clicked what in my member area?
- How to gets users EMAIL by their USERNAME
- Get user meta on registration hook
- Storing data to database and user registration
- add_user_meta() vs update_user_meta()
- How to get user meta value in wordpress
- How to display checkbox meta array values one by one?
- get user role value as a string from wp usermeta table into custom script
- How can I include user meta information in the resulting array of a WP_User_Query?
- Get currentuserinfo firstname and lastname
- How to toggle delete/update user meta values?
- Create a dropdown list displaying users meta data
- Multidimensional array problem with update_post_meta [duplicate]
- Sort users by custom user meta value
- CRM and newsletter integration? [closed]
- Strip Twitter Username from Profile Field with URL and Save to New Profile Field
- Update another users meta
- WP_User_Query get_count issue with meta_query relation