| | 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 (?) |
| | 65 | * @param array $illegal_names |
| | 66 | * @return array |
| | 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 | if( is_network_admin() && isset( $_POST['blog'] ) ) { |
| | 73 | $blog = $_POST['blog']; |
| | 74 | $domain = ''; |
| | 75 | if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) |
| | 76 | $domain = strtolower( $blog['domain'] ); |
| | 77 | |
| | 78 | if( username_exists( $domain ) ) |
| | 79 | $illegal_names[] = $domain; |
| | 80 | |
| | 81 | } else { |
| | 82 | $illegal_names[] = buddypress()->signup->username; |
| | 83 | } |
| | 84 | |
| | 85 | return $illegal_names; |
| | 86 | } |
| | 87 | |
| | 88 | add_filter( 'subdirectory_reserved_names', 'bp_members_signup_with_subdirectory_blog', 10, 1 ); |
| | 89 | |
| | 90 | /** |