If you just want to write a single <option>
for the current user, you can get the user object from wp_get_current_user() – you don’t need a WP_User_Query at all:
function getСurrentUserForFilter() {
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
echo '<option value="'.$user->ID.'">'.esc_html($user->user_email).'</option>';
}
}
Related Posts:
- How to filter users on admin users page by custom meta field?
- How to bulk delete all users with no posts?
- How can I add information underneath the user’s name on the users.php page?
- How may I filter get_users() similarly to pre_get_posts?
- Filter users by custom colum not meta key
- How to replace username with email address in users table
- How would I be able to use a font awesome icon as a user’s avatar?
- Register new user, assign custom role then send email
- How can i filter wordpress users by custom feild?
- How to pass a variable between filter/action functions?
- WP_Query filter by custom meta
- WordPress: Issue with filtering users using date range
- Custom registration field to SQL database
- How do you disable the verification process of user email changes?
- Filter and manipulate the get_current_user() function
- Add custom options to the wplink dialog
- Filter specific shortcode output?
- Insert new element to array with add_filter
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- Is calling function_exists() faster or slower that apply_filters()
- Filtered query_vars becomes global. Why does this work?
- How to disable all WordPress emails modularly and programatically?
- Allow Profile HTML for select users
- Alter only the page title, not the post titles within
- Load different template file when condition met?
- Search with filters and title
- Filter all html output
- How can override a add_filter of a plugin?
- Adding Filter Conditionally Per Page ID
- failed to filter hook `get_terms_defaults`
- Nested calls the the_content filter
- How to change domain used when pinging sites
- Filter list by a unique meta value dilemma
- How to use shortcode attribute in separate function
- Is it possible to track down Actions and Filters?
- How to filter a wordpress core function?
- Adding id and class to the search input in WordPress search form
- Multiple filters for wp_get_archive
- get_bookmarks filter not supplying query argument (wp 3.1)
- Filter and modify entry-footer link in twentyseventeen
- Filter Posts by current Month
- Break out of wordpress filter
- Are there actions or filters I can use for Ajax calls?
- How to filter for user registration, be able to throw error message
- No ‘Access-Control-Allow-Origin’ header is present [closed]
- How to make custom column Admin>Users sortable?
- How to prepare WordPress Rest data for Preview Changes?
- Admin filter for product SKU?
- Contact Form 7: Make field required after checkbox is checked
- Customize title, description and focused keyword [closed]
- Filter pre_get_posts does not modify Mine/All/Pending
- wp_mail works with add_action(‘save_post’, …) but not an ajax action
- Can i use multiple ‘the_content’ filters?
- Is it possible to put the add-filter()-hook into a function?
- How can I return shortcode output to the top of the content?
- separate categories with comma and srounded by single quote
- the_excerpt filter doesn’t work as expected
- How to filter link?
- What is the earliest hook to modify post content?
- How to modify only part of a function through the filter
- How can I apply filters in my class that extends Walker_Nav_Menu?
- How should I be using filters and is_single together?
- How to edit embed filter for youtube video to allow responsive full width layout
- Remove get_template_part() from custom theme
- How to access page variable inside action hook
- Shorten the title length
- Problem with Class, Filters and Callbacks
- Renaming wordpress login and get new password button
- Hook in a sidebar widget and add some markup
- preg_match() not working with post content
- Search a title word through query_posts (not the exact match)
- Parse a shortcode differently based on on what it’s nested in
- Elementor Image Hover + Filter Grid [closed]
- How to redirect template_directory to subdomain relativ url?
- ‘manage_users_custom_column’ is a filter, but ‘manage_posts_custom_column’ is an action. Why?
- comment_notification_text filter not working
- Line Breaks are stripped off when direction property is found
- Scanning for custom embed and prefetching
- WordPress remove_filter not working
- How to exclude or include categories in wp rest API without query parameters?
- Remove and replace woocommerce add to cart button [closed]
- Hook to change the site URL
- Replace a specific URL on all apperances on the Website (Maybe a filter?)
- Strange behaviour of REGEX in a WordPress filter (trying to suppress emtpy paragraphs)
- Modify Contextual Help
- WordPress set featured image to first image of the post
- Modify WordPress search behaviour in backend?
- Re-order search results with posts_orderby filter and post meta value
- ‘the_content’ Filter delivers empty string with lengh (608)
- Testing requested query in pre_get_posts
- Output dynamic_sidebar_params in wp_head
- Converting restricted html in comments to bbcode
- What is the proper/best way to have multiple add_filter for wp-job-manager-resume
- Modify WooCommerce email shipping text value
- Using Filters To Change Page Title
- using posts_where for meta data on pre_get_posts
- can’t output gray scaled image I’ve created using add_image_size
- How properly write function to filter content in a template for plugin “multiple content blocks”
- Change password reqts with NO plugin without breaking resetpass link?
- How can I conditionally add the filter option_home?