Skip to:
Content

BuddyPress.org

Changeset 9478


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)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-functions.php

    r9428 r9478  
    433433
    434434            // 'register' and 'activate' do not have components, but should be whitelisted.
    435             if ( bp_get_signup_allowed() && ( 'register' === $component_name || 'activate' === $component_name ) ) {
     435            if ( 'register' === $component_name || 'activate' === $component_name ) {
    436436                continue;
    437437            }
  • trunk/tests/phpunit/testcases/admin/functions.php

    r9139 r9478  
    121121        buddypress()->active_components = $ac;
    122122    }
     123
     124    /**
     125     * @group bp_core_activation_notice
     126     */
     127    public function test_bp_core_activation_notice_register_activate_pages_notcreated_signup_allowed() {
     128        $bp = buddypress();
     129        $reset_bp_pages = $bp->pages;
     130        $reset_admin_notices = $bp->admin->notices;
     131
     132        // Reset pages
     133        $bp->pages = bp_core_get_directory_pages();
     134
     135        add_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     136
     137        bp_core_activation_notice();
     138
     139        remove_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     140
     141        $missing_pages = array();
     142        foreach( buddypress()->admin->notices as $notice ) {
     143            preg_match_all( '/<strong>(.+?)<\/strong>/', $notice['message'], $missing_pages );
     144        }
     145
     146        $this->assertContains( 'Register', $missing_pages[1] );
     147        $this->assertContains( 'Activate', $missing_pages[1] );
     148
     149        // Reset buddypress() vars
     150        $bp->pages = $reset_bp_pages;
     151        $bp->admin->notices = $reset_admin_notices;
     152    }
     153
     154    /**
     155     * @group bp_core_activation_notice
     156     */
     157    public function test_bp_core_activation_notice_register_activate_pages_created_signup_allowed() {
     158        $bp = buddypress();
     159        $reset_bp_pages = $bp->pages;
     160        $reset_admin_notices = $bp->admin->notices;
     161
     162        add_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     163
     164        $ac = buddypress()->active_components;
     165        bp_core_add_page_mappings( array_keys( $ac ) );
     166
     167        // Reset pages
     168        $bp->pages = bp_core_get_directory_pages();
     169
     170        bp_core_activation_notice();
     171
     172        remove_filter( 'bp_get_signup_allowed', '__return_true', 999 );
     173
     174        $missing_pages = array();
     175        foreach( buddypress()->admin->notices as $notice ) {
     176            preg_match_all( '/<strong>(.+?)<\/strong>/', $notice['message'], $missing_pages );
     177        }
     178
     179        $this->assertNotContains( 'Register', $missing_pages[1] );
     180        $this->assertNotContains( 'Activate', $missing_pages[1] );
     181
     182        // Reset buddypress() vars
     183        $bp->pages = $reset_bp_pages;
     184        $bp->admin->notices = $reset_admin_notices;
     185    }
    123186}
  • 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.