Aurangajeb

Allow plus sign during registration

Jul 10th, 2021 (edited)
1,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. /** Use below filter to allow plus sign during registration **/
  2.  
  3. function allow_plus_sign($username, $raw_username, $strict) {
  4.     $new_username = strip_tags($raw_username);
  5.     // Kill octets
  6.     $new_username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $new_username);
  7.     $new_username = preg_replace('/&.?;/', '', $new_username); // Kill entities
  8.  
  9.    // If strict, reduce to ASCII for max portability.
  10.    if ( $strict )
  11.         $new_username = preg_replace('|[^a-z0-9 _.\-@+]|i', '', $new_username);
  12.  
  13.     return $new_username;
  14. }
  15. add_filter( 'sanitize_user', 'allow_plus_sign', 10, 3);
  16. add_action( 'wpuf_after_register', 'allow_plus_sign', 10, 3 );
Add Comment
Please, Sign In to add comment