Changeset 11155
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/classes/class-bp-members-admin.php
r11141 r11155 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 … … 232 236 // Filter WP admin users list table to include users of the specified type. 233 237 add_filter( 'pre_get_users', array( $this, 'users_table_filter_by_type' ) ); 238 } 239 } 240 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 bp_core_add_page_mappings( array( 252 'register' => 1, 253 'activate' => 1 254 ) ); 255 } 256 } 257 258 /** 259 * Create registration pages when single site registration is turned on. 260 * 261 * @since 2.7.0 262 * 263 * @param string $old_value 264 * @param string $value 265 */ 266 public function single_site_registration_on( $old_value, $value ) { 267 // Single site. 268 if ( ! is_multisite() && ! empty( $value ) ) { 269 bp_core_add_page_mappings( array( 270 'register' => 1, 271 'activate' => 1 272 ) ); 234 273 } 235 274 } -
trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php
r9819 r11155 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 }
Note: See TracChangeset
for help on using the changeset viewer.