Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/12/2015 07:00:06 PM (9 years ago)
Author:
imath
Message:

Make sure Site admins can set the "register" and "activate" pages in the pages association settings screen even if signups are not allowed

In 2.2, when signups are not allowed, it is not possible to associate a WordPress page to the register or the activate specific components. It introduced some confusion for some site admins and had an impact on plugins allowing users to invite others.

We will keep on working on the best way to deal with these directory pages in the next release. In the meantime, we are bringing back the possibility to always set the association for the register and the activate specific components.

props boonebgorges

See #6176
Fixes #6197 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/functions.php

    r9417 r9478  
    568568        remove_filter( 'bp_get_signup_allowed', '__return_true', 999 );
    569569
     570        // Get page ids
     571        $page_ids = bp_core_get_directory_page_ids();
     572
     573        // Need to delete these pages as previously created.
     574        wp_delete_post( $page_ids['register'], true );
     575        wp_delete_post( $page_ids['activate'], true );
     576
    570577        add_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     578        bp_core_add_page_mappings( array_keys( $ac ) );
    571579        $page_ids = bp_core_get_directory_page_ids();
    572580        remove_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     
    576584        $this->assertNotContains( 'register', $page_names );
    577585        $this->assertNotContains( 'activate', $page_names );
     586    }
     587
     588    /**
     589     * @group bp_core_get_directory_pages
     590     */
     591    public function test_bp_core_get_directory_pages_register_activate_page_created_signups_allowed() {
     592        add_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     593
     594        $ac = buddypress()->active_components;
     595        bp_core_add_page_mappings( array_keys( $ac ) );
     596        $directory_pages = bp_core_get_directory_pages();
     597
     598        remove_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     599
     600        $this->assertTrue( isset( $directory_pages->register ) );
     601        $this->assertTrue( isset( $directory_pages->activate ) );
     602
     603        $r = get_post( $directory_pages->register->id );
     604        $this->assertTrue( 'publish' == $r->post_status );
     605
     606        $a = get_post( $directory_pages->activate->id );
     607        $this->assertTrue( 'publish' == $a->post_status );
     608    }
     609
     610    /**
     611     * @group bp_core_get_directory_pages
     612     */
     613    public function test_bp_core_get_directory_pages_register_activate_page_notcreated_signups_allowed() {
     614        add_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     615
     616        $ac = buddypress()->active_components;
     617        bp_core_add_page_mappings( array_keys( $ac ) );
     618
     619        remove_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     620
     621        add_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     622
     623        $directory_pages = bp_core_get_directory_pages();
     624
     625        remove_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     626
     627        $this->assertFalse( isset( $directory_pages->register ) );
     628        $this->assertFalse( isset( $directory_pages->activate ) );
     629    }
     630
     631    /**
     632     * @group bp_core_get_directory_pages
     633     */
     634    public function test_bp_core_get_directory_pages_register_activate_page_created_signups_notallowed() {
     635        add_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     636
     637        $ac = buddypress()->active_components;
     638        bp_core_add_page_mappings( array_keys( $ac ) );
     639
     640        remove_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     641
     642        add_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     643
     644        $directory_pages = bp_core_get_directory_pages();
     645
     646        remove_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     647
     648        $this->assertTrue( isset( $directory_pages->register ) );
     649        $this->assertTrue( isset( $directory_pages->activate ) );
     650
     651        $r = get_post( $directory_pages->register->id );
     652        $this->assertTrue( 'publish' == $r->post_status );
     653
     654        $a = get_post( $directory_pages->activate->id );
     655        $this->assertTrue( 'publish' == $a->post_status );
     656    }
     657
     658    /**
     659     * @group bp_core_get_directory_pages
     660     */
     661    public function test_bp_core_get_directory_pages_register_activate_page_notcreated_signups_notallowed() {
     662
     663        add_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     664
     665        $ac = buddypress()->active_components;
     666        bp_core_add_page_mappings( array_keys( $ac ) );
     667        $directory_pages = bp_core_get_directory_pages();
     668
     669        remove_filter( 'bp_get_signup_allowed', '__return_false', 999 );
     670
     671        $this->assertFalse( isset( $directory_pages->register ) );
     672        $this->assertFalse( isset( $directory_pages->activate ) );
    578673    }
    579674
Note: See TracChangeset for help on using the changeset viewer.