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
- add_user_meta() vs update_user_meta()
- 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
- Get basic Image Uploader on User Profile Page
- Return all users with a specific meta key
- Capabilities Vs User Meta
- Problem storing arrays with update_user_meta
- wp_get_current_user always returns 0
- get_users is expecting unserialized meta_value
- 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
- how to get specific fields from get_user_meta()
- WP_User_Query with combined meta query – not working?
- Validating a new user registration field
- User meta to post
- Searching user meta using WP_User_Query
- 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?
- Add profile field (usermeta) to Add New User
- very last action before during user registration before he is redirected to homepage
- Customizing WP tables or adding new ones?
- How to Make admin Sidebar Menu always be Collapse by code
- Are the default entries for a user in wp_usermeta documented?
- update_user_meta adding new rows in db for same key
- User Relationship
- How to query users by meta value, even when meta key doesn’t exist?
- What is the meta-box-order_post_hash used for?
- Add a member number to new user
- Allow role to edit users at lower level with only specific metadata
- Hook or action to save profile fields at specific time
- User meta conventions / name registry, for social media links
- Get user’s ID on logout
- How to get the user description with get_users?
- get current user not working
- Sanitize textarea instead of input
- Multiple User-Meta Values in One User-Meta Key
- Getting $user_id for the_author_meta outside the loop in multisite
- Gravity Custom Merge Tags [closed]
- No first_name or user_firstname property in WP_User object
- How to insert new element to existing array in usermeta?
- WP User Query fails when searching meta queries and search columns
- Possible bug: update_user_meta is updating two unique meta entries
- Update user meta through a front end form
- What is the difference between get_the_author_meta() and get_user_meta()?
- How to display current_user bio
- Is a user_meta research case-sensitive or not
- Store user’s registration date as meta
- Query users by capability – uninstall/deactivate callback
- Can I prevent “wp_user_level” from getting added to wp_usermeta on registration?
- Get the Google+ and Twitter links – WordPress SEO plugin
- How to tell whether a user meta value has increased or decreased [closed]
- Adding current user’s ID to the end of PDF hyperlinks in post content
- update_user_meta() not working
- How to display user’s avatar on their profile page?
- Send mail to user only once when specific check box is selected and updated from profile meta updated by admin
- WP_user_query throws a 404 error
- WP_User_Query pulling ACF to loop
- Incrementally add or substract from usermeta field
- 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
- set a user-meta key as avatar
- Prevent update of custom user profile meta field on the front end after 1st entry
- 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?
- strange issue with user_meta + json_encode/decode
- Inserting and finding multiple values in user-meta fields
- Update user meta on logout
- update_user_meta after wordpress in action hooks
- Adding user data to an existing user_id
- I want to update my user meta table
- Problem to wp_hash
- trying to determine if meta value exists for user and if not auto submit gravity form to redirect
- Passing args to WP_User_Query am I using meta correctly?
- Subscribers Group User meta delete
- action user_new_form param is a string
- Redirecting users based on custom user meta
- Customize Avatar using user meta
- get_user_meta returning old data
- Why does the usermeta table contain html entities?
- get_user_meta returning empty when it’s NOT empty
- How can I programmatically show a specific (template) page, like author.php?
- Multiple meta values for one meta key
- When is a user’s meta data table loaded?
- Display and Update User Custom Meta via user-edit.php