Ticket #7193: 7193.auto-create.patch
File 7193.auto-create.patch, 4.5 KB (added by , 8 years ago) |
---|
-
src/bp-members/bp-members-template.php
2509 2509 function bp_get_signup_allowed() { 2510 2510 $bp = buddypress(); 2511 2511 2512 $signup_allowed = false; 2513 2514 if ( is_multisite() ) { 2515 $registration = bp_core_get_root_option( 'registration' ); 2516 2517 if ( in_array( $registration, array( 'all', 'user' ) ) ) { 2518 $signup_allowed = true; 2519 } 2520 2521 } else { 2522 if ( bp_get_option( 'users_can_register') ) { 2523 $signup_allowed = true; 2524 } 2525 } 2512 $signup_allowed = (bool) bp_get_option( 'users_can_register' ); 2526 2513 2527 2514 /** 2528 2515 * Filters whether or not new signups are allowed. -
src/bp-members/classes/class-bp-members-admin.php
214 214 add_filter( "views_{$user_screen}", array( $this, 'signup_filter_view' ), 10, 1 ); 215 215 add_filter( 'set-screen-option', array( $this, 'signup_screen_options' ), 10, 3 ); 216 216 } 217 218 // Registration is turned on. 219 add_action( 'update_site_option_registration', array( $this, 'multisite_registration_on' ), 10, 2 ); 220 add_action( 'update_option_users_can_register', array( $this, 'single_site_registration_on' ), 10, 2 ); 217 221 } 218 222 219 223 /** Users List - Members Types *************************************** … … 235 239 } 236 240 237 241 /** 242 * Create registration pages when multisite user registration is turned on. 243 * 244 * @since 2.7.0 245 * 246 * @param string $option_name Current option name; value is always 'registration'. 247 * @param string $value 248 */ 249 public function multisite_registration_on( $option_name, $value ) { 250 if ( 'user' === $value || 'all' === $value ) { 251 // Uh what? 252 bp_core_add_page_mappings( array( 'pizza' ) ); 253 } 254 } 255 256 /** 257 * Create registration pages when single site registration is turned on. 258 * 259 * @since 2.7.0 260 * 261 * @param string $old_value 262 * @param string $value 263 */ 264 public function single_site_registration_on( $old_value, $value ) { 265 // Single site. 266 if ( ! is_multisite() && ! empty( $value ) ) { 267 // Uh what? 268 bp_core_add_page_mappings( array( 'pizza' ) ); 269 } 270 } 271 272 /** 238 273 * Get the user ID. 239 274 * 240 275 * Look for $_GET['user_id']. If anything else, force the user ID to the -
tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php
285 285 // Now verify that our BP activity page was not wiped out 286 286 $this->assertNotEmpty( $dir_pages->activity ); 287 287 } 288 289 /** 290 * @ticket BP7193 291 */ 292 public function test_bp_core_get_directory_pages_autocreate_register_pages_single_site() { 293 if ( is_multisite() ) { 294 return; 295 } 296 297 // Emulate being in the admin area. 298 if ( ! class_exists( 'BP_Members_Admin', false ) ) { 299 require BP_PLUGIN_DIR . 'bp-members/classes/class-bp-members-admin.php'; 300 } 301 $admin = new BP_Members_Admin; 302 add_action( 'update_option_users_can_register', array( $admin, 'single_site_registration_on' ), 10, 2 ); 303 304 // Emulate turning registration on. 305 update_option( 'users_can_register', 1 ); 306 307 // Now check directory pages. 308 $pages = bp_core_get_directory_pages(); 309 310 $this->assertNotEmpty( $pages->register ); 311 $this->assertNotEmpty( $pages->activate ); 312 313 remove_action( 'update_option_users_can_register', array( $admin, 'single_site_registration_on' ), 10, 2 ); 314 } 315 316 /** 317 * @ticket BP7193 318 */ 319 public function test_bp_core_get_directory_pages_autocreate_register_pages_multisite() { 320 if ( ! is_multisite() ) { 321 return; 322 } 323 324 // Emulate being in the network admin area. 325 if ( ! class_exists( 'BP_Members_Admin', false ) ) { 326 require BP_PLUGIN_DIR . 'bp-members/classes/class-bp-members-admin.php'; 327 } 328 $admin = new BP_Members_Admin; 329 add_action( 'update_site_option_registration', array( $admin, 'multisite_registration_on' ), 10, 2 ); 330 331 // Emulate turning registration on. 332 update_site_option( 'registration', 'user' ); 333 334 // Now check directory pages. 335 $pages = bp_core_get_directory_pages(); 336 337 $this->assertNotEmpty( $pages->register ); 338 $this->assertNotEmpty( $pages->activate ); 339 340 remove_action( 'update_site_option_registration', array( $admin, 'multisite_registration_on' ), 10, 2 ); 341 } 288 342 }