| | 57 | * Make sure the username is not the blog slug in case of root profile & subdirectory blog |
| | 58 | * |
| | 59 | * If BP_ENABLE_ROOT_PROFILES is defined & multisite config is set to subdirectories, |
| | 60 | * then there is a chance site.url/username == site.url/blogslug. If so, user's profile |
| | 61 | * is not reachable, instead the blog is displayed. This filter makes sure the signup username |
| | 62 | * is not the same than the blog slug for this particular config. |
| | 63 | * |
| | 64 | * @since BuddyPress (2.1.0) |
| | 65 | * @param array $illegal_names |
| | 66 | * @return array $illegal_names |
| | 67 | */ |
| | 68 | function bp_members_signup_with_subdirectory_blog( $illegal_names = array() ) { |
| | 69 | if ( ! bp_core_enable_root_profiles() ) { |
| | 70 | return $illegal_names; |
| | 71 | } |
| | 72 | |
| | 73 | if ( is_network_admin() && isset( $_POST['blog'] ) ) { |
| | 74 | $blog = $_POST['blog']; |
| | 75 | $domain = ''; |
| | 76 | |
| | 77 | if ( preg_match( '|^([a-zA-Z0-9-])$|', $blog['domain'] ) ) { |
| | 78 | $domain = strtolower( $blog['domain'] ); |
| | 79 | } |
| | 80 | |
| | 81 | if ( username_exists( $domain ) ) { |
| | 82 | $illegal_names[] = $domain; |
| | 83 | } |
| | 84 | |
| | 85 | } else { |
| | 86 | $illegal_names[] = buddypress()->signup->username; |
| | 87 | } |
| | 88 | |
| | 89 | return $illegal_names; |
| | 90 | } |
| | 91 | add_filter( 'subdirectory_reserved_names', 'bp_members_signup_with_subdirectory_blog', 10, 1 ); |
| | 92 | |
| | 93 | /** |