bp_core_get_illegal_names

Add BuddyPress-specific items to the illegal_names array.

Description

(array) bp_core_get_illegal_names( (string) $value = '', (string) $oldvalue = '' ); 

Returns (array)

Merged and unique array of illegal names.

Parameters (2)

0. $value — Optional. (string) => ''
Illegal names as being saved defined in Multisite settings.
1. $oldvalue — Optional. (string) => ''
The old value of the option.

Usage

  1. if ( !function_exists( 'bp_core_get_illegal_names' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // Illegal names as being saved defined in 
  5. // Multisite settings. 
  6. $value = ''; 
  7.  
  8. // The old value of the option. 
  9. $oldvalue = ''; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bp_core_get_illegal_names($value, $oldvalue); 
  13.  

Defined (1)

The function is defined in the following location(s).

/bp-members/bp-members-functions.php  
  1. function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) { 
  2.  
  3. // Make sure $value is array. 
  4. if ( empty( $value ) ) { 
  5. $db_illegal_names = array(); 
  6.  
  7. if ( is_array( $value ) ) { 
  8. $db_illegal_names = $value; 
  9. } elseif ( is_string( $value ) ) { 
  10. $db_illegal_names = explode( ' ', $value ); 
  11.  
  12. // Add the core components' slugs to the banned list even if their components aren't active. 
  13. $bp_component_slugs = array( 
  14. 'groups',  
  15. 'members',  
  16. 'forums',  
  17. 'blogs',  
  18. 'activity',  
  19. 'profile',  
  20. 'friends',  
  21. 'search',  
  22. 'settings',  
  23. 'notifications',  
  24. 'register',  
  25. 'activate' 
  26. ); 
  27.  
  28. // Core constants. 
  29. $slug_constants = array( 
  30. ); 
  31. foreach( $slug_constants as $constant ) { 
  32. if ( defined( $constant ) ) { 
  33. $bp_component_slugs[] = constant( $constant ); 
  34.  
  35. /** 
  36. * Filters the array of default illegal usernames. 
  37. * @since 1.2.2 
  38. * @param array $value Merged and unique array of illegal usernames. 
  39. */ 
  40. $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) ); 
  41.  
  42. // Merge the arrays together. 
  43. $merged_names = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names ); 
  44.  
  45. // Remove duplicates. 
  46. $illegal_names = array_unique( (array) $merged_names ); 
  47.  
  48. /** 
  49. * Filters the array of default illegal names. 
  50. * @since 1.2.5 
  51. * @param array $value Merged and unique array of illegal names. 
  52. */ 
  53. return apply_filters( 'bp_core_illegal_names', $illegal_names );