I think the problem is you are passing the WP_User_Query object, not the results of the query. Try to change:
$fields = array(
array(
'id' => $prefix . 'user_sub',
'name' => 'Subscriber User',
'type' => 'select',
'use_ajax' => false,
'options' => $user_query, // this is where you populate the select in metabox
),
);
To:
$users_ids = array();
if ( !empty( $user_query->results )){
foreach($user_query->results as $user){
$users_ids[] = $user->ID;
}
}
$fields = array(
array(
'id' => $prefix . 'user_sub',
'name' => 'Subscriber User',
'type' => 'select',
'use_ajax' => false,
'options' => $users_ids, // this is where you populate the select in metabox
),
);
Related Posts:
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- Individual Widgets per Page
- Using TinyMce with textareas in meta boxes on custom post types
- How to add add_meta_box to specific Page Template?
- Can I count the number of users matching a value in a multiple value key?
- How to get users by a custom field / by user meta data?
- Adding another state (spam, reject, approve) to wordpress comments?
- How do you add a custom option to user data?
- extend Meta Box / Document Panel
- Add multiple images to a page sidebar
- Populating meta box with select-list of existing posts, and assigning it to custom post types
- Show User Their Password
- Create meta boxes that don’t show in custom fields
- How To Create a Metabox of HTML Content with Instructions For Editors When Editing a Post or Page?
- How to load php file for specific page in admin?
- How to set default metaboxes on user creation?
- Metabox nonce PHP notice
- TinyMCE in Custom Metabox not loaded after upgrading from WP 3.1.4 to WP 3.2
- wp_editor in add_meta_boxes does not show gallery
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- Create custom field key upon theme activation
- Problem with adding exta field in metabox in custom post type
- How can I sort get_users() by any value (last_name, user defined fields and more)
- How do I add custom_meta_box_id’s value?
- add meta box using function.php
- Metabox image upload and custom field
- all tincymce’s switch when updating page after changing from html to text in custom metabox
- How to construct multiple meta boxes
- Force hide custom field metaboxes
- How to Display Custom Meta Box only on Specific Page IDs
- Metabox will not save
- How do I create a column in Users list and display user data from custom registration field
- Odd PHP Code To Display HTML Of Meta Box [closed]
- custom field not saved
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Create Multiple File Upload Metabox in WordPress
- WP_User_Query pulling ACF to loop
- Better Method for Multiple Meta Boxes
- query usermeta from custom field
- custom avatar removal
- Unsaved changes in metabox inputs not detected in the block editor
- How to add upload video option in wordpress for user?
- Passing args to WP_User_Query am I using meta correctly?
- Button inside Custom Meta Box triggering the Update Button
- How to save the date/time of last update of an extra user profile field?
- How can you include custom post meta in search without calling each key?
- When creating a metabox do you have to create DB fields for the data?
- Specific coditional usage [closed]
- Set checkbox as checked by default in a metabox
- Singleton Custom Field (Meta Box)
- Custom metabox not displaying multiselect data in edit mode
- How to validate select field in post meta?
- Show image if author meta (profile fields) exists outside loop
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- How to add fields in custom registration form, validate it and aave to db? [closed]
- Is it preferable to use custom code to create metaboxes instead of plugins (such as ACF) and if so why? [closed]
- check for duplicate user meta data before updating
- How add multiple wp_editor_box to new post
- Increment user meta data by 1 each time a page is visited
- Front-End User Profile
- Get emails from users by custom field SQL
- award points to a user each time they update their cpt post
- Displaying pages with a specific custom meta
- How to update user profile custom fields
- Enable a short code in the custom meta field
- How to validation for sanitize_URL?
- put saved metabox values back into fields and then display on the front end
- HM CMB: Role Select
- Custom metabox not working
- Trying to implement AJAX into my admin pages. Am I improperly enqueue and localizing my scripts?
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- How to Convert Custom Fields from Text to Array?
- WP E-Commerce Custom Meta > Serialized array
- Display Additional Info
- Populate custom checkout fields with data from previous orders
- show a specific metabox dependent on the page template
- User query – getting values for custom meta keys/fields
- How to get data from user meta custom fields created with acf-pro plugin?
- Making custom meta box required (with error message if not filled in) on Gutenberg
- HTML for adding a meta box (basic text field) to page editor?
- How to save multiple values with same meta_key, each value linked to another tag id
- How to improve my non-unique metadata MySQL entries?
- Adding text box with add_meta_box
- Add forms dynamically in admin pages?
- How can I ‘check’ the “custom fields” box from the Screen Options?
- author.php not showing content if Author has no Posts
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- If metabox fields has content display content
- Append custom field items to content from plugin
- update_user_meta(): invisible data storage
- Display Data From This Custom Media Upload Meta Box?
- When post is updated, custom metadata in text area field is overwritten
- Call the latest posts from a custom field group to be displayed on front-page
- My meta boxes update wp_postmeta of posts but not of pages. What is wrong with the code?
- Can i categorise my meta box?
- When editing a post with a custom meta box the values aren’t displaying correctly
- Use Metabox to enter Post Title
- Include custom fields into the content of a regular page
- How to get the value of particular get $meta value in wordpress
- Can’t sort custom column on user.php by number / meta_value_num?