You can store the user meta in a variable and check if the variable is empty or not, like below-
$args = array(
'role' => 'subscriber',
'meta_key' => 'user_designation'
);
// The Query
$user_query = new WP_User_Query($args);
// User Loop
$u_meta_array = array();
if ( !empty($user_query->results) ) {
foreach ( $user_query->results as $user ) {
$u_meta = get_user_meta($user->ID, 'user_designation', true);
if (!empty($u_meta)){
$u_meta_array[] = $u_meta;
}
}
$u_meta_array_unique = array_unique($u_meta_array);
foreach ($u_meta_array_unique as $u ) {
echo '<option>' . $u . '</option>';
}
} else { ?>
<option value="0">No Category Found</option>
<?php } ?>
Hope that thing is gonna work. Please let me know if it works or not.
Related Posts:
- Return all users with a specific meta key
- get_users is expecting unserialized meta_value
- How to get the user description with get_users?
- get current user not working
- Is a user_meta research case-sensitive or not
- Randomize Users
- How get meta from all users?
- get random users each time based on the meta key
- Storing data to database and user registration
- Adding fields to the “Add New User” screen in the dashboard
- Difference between update_user_meta and update_user_option
- Check if user is admin by user ID
- Get basic Image Uploader on User Profile Page
- Capabilities Vs User Meta
- Where the Nickname is being used in WordPress
- How to create a template for a custom URI associated with the user
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- User meta to post
- Where to Store Custom User Fields
- Display sortable User meta column in admin panel user’s page
- Add profile field (usermeta) to Add New User
- How to Make admin Sidebar Menu always be Collapse by code
- Extra User Profile Field Upload File / Image
- How to query users by meta value, even when meta key doesn’t exist?
- Does wp_delete_user() remove all user content?
- WP User Query fails when searching meta queries and search columns
- Possible bug: update_user_meta is updating two unique meta entries
- How to display current_user bio
- Updating user meta
- Query users by capability – uninstall/deactivate callback
- How to tell whether a user meta value has increased or decreased [closed]
- How to pass user meta_key and meta_value (values as array)
- Want to Add Custom Fields for Uploading video to WordPress Users from front end
- how to delete all users and posts based on ‘user_meta’?
- Are User Levels Still Currently Used?
- WPML Default Language User Meta [closed]
- WP_user_query throws a 404 error
- WP_User_Query pulling ACF to loop
- Incrementally add or substract from usermeta field
- Search Users base on meta_value & meta_key
- get_user_meta an ID for multiple functions
- Column Sorting Code on users.php
- Update user meta on logout
- Adding user data to an existing user_id
- Creating user without username and password
- Passing args to WP_User_Query am I using meta correctly?
- action user_new_form param is a string
- Customize Avatar using user meta
- Query posts based on the meta key values of logged-in users?
- Is this code true or not
- The Simple and Correct Way to Add User Meta
- “Select your country” landing page. Remember user choice
- Using xprofile_insert_field
- Getting list of top 10 users and sort on last name
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Associate multiple email addresses with the same user account, so they can log in with either
- how to set default update_user_meta values wordpress
- Show extra user profile meta for current user
- Pulling member name from WordPress URL
- Update a user profile via frontend
- Cannot Update user meta in custom field
- Can I Create a Second Admin Level User Role?
- Recovering the table wp_usermeta from users
- Remove fields from WordPress profile
- User meta and public function security
- How to save a label for an extra user meta field and to display it later?
- Display user meta data from a textarea as a formated text
- What does “link” refer to when you delete a user?
- Mass Update User Profile Checkbox Options
- Wrong result in fetching User meta of WordPress
- Delete user meta ( delete_user_meta ) by key without user id
- Why is my Custom User Meta deleted on Profile Update?
- Getting user data via ajax
- Edit a user profile field on front end
- How To Export User’s Custom Fields in CSV or XLSX
- wp_get_current_user Not working
- How to set a user meta key value based on another user meta key value
- How to get the id of recently registered user from database?
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- Saving an array of values (file urls) to update_user_meta()?
- user and usermeta table not found
- Confusing problem with displaying message recipient metadata
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Updating custom user meta
- Require confirmation of current user’s email before updating database and before send_email_change_email
- How do I change the user via SQL?
- get user role value as a string from wp usermeta table into custom script
- User list order by user meta
- Get currentuserinfo firstname and lastname
- How to query authors by custom taxonomy?
- Create a dropdown list displaying users meta data
- Get author meta of all writers
- Let users register weight each day and save it in DB
- Using IDX feed to display agent’s and listings with agent’s info associated for Real Estate Website
- Custom user meta data [closed]
- Problem with update_user_meta() meta_value
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box
- WordPress – Security Question at Login from User’s Meta Data
- MySQL query to list users who never signed in
- Can’t display user bio