Like so:
function my_validate_username( $valid, $username ) {
$sanitized = sanitize_user( $username, false );
$valid = ( $sanitized == $username );
return $valid;
}
add_filter('validate_username', 'my_validate_username', 10, 2);
Related Posts:
- How to show page content in feed?
- Sanitize and data validation with apply_filters() function
- How many filter/action hooks are healthy?
- remove_filter( ‘the_content’, ‘wpautop’ ); only for certain post types
- Valid characters for actions, hooks and filters
- How to hook into unregistering a widget instance?
- How do I use the ‘http_request_host_is_external’ filter
- get_option() filtering and getting out of recursion
- Get excerpt from $post->post_content
- AJAX filter posts on click based on category
- How can I filter Microsoft Word gunk from pasted content?
- Can I add custom meta for each image uploaded via media-upload.php?
- How do I know if author field was changed on post save?
- Load different template file when condition met?
- WordPress 3.5+ upload tool filter
- Some questions regarding filter
- Use content custom filter for all shortcodes
- Filter all html output
- Problem getting single_template filter to work – I want to serve a different single.php file for posts in a certain category
- Too many actions/filters!
- Which hook is fired when inserting media into a post
- How can override a add_filter of a plugin?
- Adding Filter Conditionally Per Page ID
- How to specify which category of the post to use in case of multiple categories
- Return array of images after content
- Nested calls the the_content filter
- How to change domain used when pinging sites
- How to remove google font in WordPress for only single page?
- How do I filter get_the_excerpt() but keep all of its functionality intact?
- Why anything done on comments_array hook gets reset?
- How to add a class to Tag cloud widget link?
- How to get all the predefined do_action() calls from an active theme
- Is there a get_post(s) filter that can alter/replace the output completely?
- WooCommerce Variable Product Price – Where is “From” text generated from?
- get_header and hook avoid normal call
- Dropdown filter in custom posts
- add_filter does not work as expected
- How to order by taxonomy using wp_query
- Filter taxonomy admin pagination
- Feed, RSS not able to clear the cache and cannot change the limit of cache life time
- WP action/filter to modify title before header output and article output?
- Custom view counts not updating correctly
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- To add a custom filter based on a meta field
- How to create Woocommerce Product Filter Widget [closed]
- Add default user field to WooCommerce checkout [closed]
- Filter to shorten column content on edit-tags.php
- Filtering Comment Reply Links (comment_reply_link_args) for “infinite replies” in nested comments
- Create Search Form to Filter Through Terms
- Formatting get_post content doesn’t allow JS content to function properly
- Proper after_setup_theme and wp_head cleanup
- Why doesn’t remove_action work in my plugin?
- Using a filter to modify Genesis wp_nav_menu
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- How can I change the email that is inside the default email texts of wordpress?
- Conditional does not work with add_filter
- Modify message displayed on post save
- Something is filtering my shortcodes… Can’t figure out what
- Pass debug_backtrace() in WordPress filter
- Remove actions/filters that are set with create_function()
- I need to hook and change language of facebook sdk
- change “missing attachment” text functions.php
- Use has_filter on comment_post
- 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
- Parse a shortcode differently based on on what it’s nested in
- return get_the_tag_list with whitespace removed
- How to redirect template_directory to subdomain relativ url?
- How do I add tags to entire comments, not just their text
- Modify author url display in edit-comments.php
- add_filter( ‘the_title’ gets through this if statement twice
- Changing the category for existing Gutenberg blocks
- Filter Post Title without affecting screen-reader-text
- Modify WordPress Page Title ()
- How to add lazy field in content endpoint using Gutenberg blocks
- how to use apply filter for Class?
- How can I see exactly what arguments are being passed through a filter so that I may modify them?
- Widget image reorganize layout
- WordPress set featured image to first image of the post
- Re-order search results with posts_orderby filter and post meta value
- Set Microsoft Word links to open in new window/tab
- WordPress get_avatar filter to match logins
- Modify category listing API response
- Auto-generated excerpt with shortcode and read more button/text link
- ‘the_content’ Filter delivers empty string with lengh (608)
- Output dynamic_sidebar_params in wp_head
- How to sort posts according to meta value?
- Converting restricted html in comments to bbcode
- Change shortcode output (filter?)
- How do I add a class to all sidebars to let a Google Custom Search Engine know not to index the content?
- How to replace all images in all posts and pages with a different size?
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- using posts_where for meta data on pre_get_posts
- Updating User Profile on Registration
- remove_filter excerpt_more from a plugin class
- How properly write function to filter content in a template for plugin “multiple content blocks”
- ACF Load Field Groups Programmatically [closed]
- Why does using excerpt_more filter change link location?