Skip to:
Content

BuddyPress.org

Ticket #3741: 3741.register.01.patch

File 3741.register.01.patch, 9.4 KB (added by r-a-y, 14 years ago)
  • bp-core/bp-core-catchuri.php

    function bp_core_load_template( $templates ) { 
    375375
    376376        // Filter the template locations so that plugins can alter where they are located
    377377        $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates );
     378
    378379        if ( !empty( $located_template ) ) {
    379380
    380381                // Template was located, lets set this as a valid page and not a 404.
    function bp_core_no_access( $args = '' ) { 
    458459        $redirect_url .= $_SERVER['REQUEST_URI'];
    459460
    460461        $defaults = array(
    461                 'mode'     => '1',                  // 1 = $root, 2 = wp-login.php
    462                 'redirect' => $redirect_url,        // the URL you get redirected to when a user successfully logs in
    463                 'root'     => bp_get_root_domain(),     // the landing page you get redirected to when a user doesn't have access
     462                'mode'     => bp_is_theme_compat() ? 2 : 1, // 1 = $root, 2 = wp-login.php
     463                'redirect' => $redirect_url,                // the URL you get redirected to when a user successfully logs in
     464                'root'     => bp_get_root_domain(),         // the landing page you get redirected to when a user doesn't have access
    464465                'message'  => __( 'You must log in to access the page you requested.', 'buddypress' )
    465466        );
    466467
    function bp_core_no_access( $args = '' ) { 
    471472        /**
    472473         * @ignore Ignore these filters and use 'bp_core_no_access' above
    473474         */
    474         $mode           = apply_filters( 'bp_no_access_mode',     $mode,     $root,     $redirect, $message );
    475         $redirect       = apply_filters( 'bp_no_access_redirect', $redirect, $root,     $message,  $mode    );
    476         $root           = apply_filters( 'bp_no_access_root',     $root,     $redirect, $message,  $mode    );
    477         $message        = apply_filters( 'bp_no_access_message',  $message,  $root,     $redirect, $mode    );
    478         $root       = trailingslashit( $root );
     475        $mode     = apply_filters( 'bp_no_access_mode',     $mode,     $root,     $redirect, $message );
     476        $redirect = apply_filters( 'bp_no_access_redirect', $redirect, $root,     $message,  $mode    );
     477        $root     = apply_filters( 'bp_no_access_root',     $root,     $redirect, $message,  $mode    );
     478        $message  = apply_filters( 'bp_no_access_message',  $message,  $root,     $redirect, $mode    );
     479        $root     = trailingslashit( $root );
    479480
    480481        switch ( $mode ) {
    481482
  • bp-core/bp-core-theme-compatibility.php

    function bp_get_theme_compat_url() { 
    175175}
    176176
    177177/**
     178 * Gets true/false if theme compatibility is on.
     179 *
     180 * @since BuddyPress (1.7)
     181 * @return bool
     182 */
     183function bp_is_theme_compat() {
     184        if ( empty( buddypress()->theme_compat->theme ) ) {
     185                return false;
     186        }
     187
     188        return true;
     189}
     190
     191/**
    178192 * Gets true/false if page is currently inside theme compatibility
    179193 *
    180194 * @since BuddyPress (1.7)
  • bp-members/bp-members-functions.php

    function bp_core_wpsignup_redirect() { 
    13961396                return;
    13971397
    13981398        // Redirect to sign-up page
    1399         if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
    1400                 bp_core_redirect( bp_get_signup_page() );
     1399        bp_core_redirect( bp_get_signup_page() );
    14011400}
    14021401add_action( 'bp_init', 'bp_core_wpsignup_redirect' );
  • bp-members/bp-members-screens.php

    function bp_core_screen_signup() { 
    178178
    179179                                        if ( !empty( $_POST['field_' . $field_id] ) )
    180180                                                $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
    181                                        
     181
    182182                                        if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) )
    183183                                                $usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
    184184                                }
    function bp_core_screen_signup() { 
    203203
    204204                                if ( is_wp_error( $wp_user_id ) ) {
    205205                                        $bp->signup->step = 'request-details';
    206                                         bp_core_add_message( $wp_user_id->get_error_message(), 'error' ); 
     206                                        bp_core_add_message( $wp_user_id->get_error_message(), 'error' );
    207207                                } else {
    208208                                        $bp->signup->step = 'completed-confirmation';
    209209                                }
    class BP_Members_Theme_Compat { 
    334334        }
    335335}
    336336new BP_Members_Theme_Compat();
     337
     338/**
     339 * The main theme compat class for BuddyPress Registration
     340 *
     341 * This class sets up the necessary theme compatability actions to safely output
     342 * registration template parts to the_title and the_content areas of a theme.
     343 *
     344 * @since BuddyPress (1.7)
     345 */
     346class BP_Registration_Theme_Compat {
     347
     348        /**
     349         * Setup the groups component theme compatibility
     350         *
     351         * @since BuddyPress (1.7)
     352         */
     353        public function __construct() {
     354                add_action( 'bp_setup_theme_compat', array( $this, 'is_registration' ) );
     355        }
     356
     357        /**
     358         * Are we looking at either the registration or activation pages?
     359         *
     360         * @since BuddyPress (1.7)
     361         */
     362        public function is_registration() {
     363
     364                // Bail if not looking at the registration or activation page
     365                if ( ! bp_is_register_page() && ! bp_is_activation_page() ) {
     366                        return;
     367                }
     368
     369                // Not a directory
     370                bp_update_is_directory( false, 'register' );
     371
     372                // Setup actions
     373                add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post'    ) );
     374                add_filter( 'bp_replace_the_content',                    array( $this, 'dummy_content' ) );
     375        }
     376
     377        /** Template ***********************************************************/
     378
     379        /**
     380         * Update the global $post with dummy data
     381         *
     382         * @since BuddyPress (1.7)
     383         */
     384        public function dummy_post() {
     385                // Registration page
     386                if ( bp_is_register_page() ) {
     387                        $title = __( 'Create an Account', 'buddypress' );
     388
     389                        if ( 'completed-confirmation' == bp_get_current_signup_step() ) {
     390                                $title = __( 'Sign Up Complete!', 'buddypress' );
     391                        }
     392
     393                // Activation page
     394                } else {
     395                        $title = __( 'Activate your Account', 'buddypress' );
     396
     397                        if ( bp_account_was_activated() ) {
     398                                $title = __( 'Account Activated', 'buddypress' );
     399                        }       
     400                }
     401
     402                $post_type = bp_is_register_page() ? 'bp_register' : 'bp_activate';
     403
     404                bp_theme_compat_reset_post( array(
     405                        'ID'             => 0,
     406                        'post_title'     => $title,
     407                        'post_author'    => 0,
     408                        'post_date'      => 0,
     409                        'post_content'   => '',
     410                        'post_type'      => $post_type,
     411                        'post_status'    => 'publish',
     412                        'is_archive'     => true,
     413                        'comment_status' => 'closed'
     414                ) );
     415        }
     416
     417        /**
     418         * Filter the_content with either the register or activate templates.
     419         *
     420         * @since BuddyPress (1.7)
     421         */
     422        public function dummy_content() {
     423                if ( bp_is_register_page() ) {
     424                        bp_buffer_template_part( 'members/register' );
     425                } else {
     426                        bp_buffer_template_part( 'members/activate' );
     427                }
     428        }
     429}
     430new BP_Registration_Theme_Compat();
  • bp-members/bp-members-template.php

    function bp_loggedin_user_username() { 
    926926/** Signup Form ***************************************************************/
    927927
    928928function bp_has_custom_signup_page() {
    929         if ( locate_template( array( 'register.php' ), false ) || locate_template( array( '/registration/register.php' ), false ) )
     929        // if we're using theme compat, we're using our own templates, return true
     930        if ( bp_is_theme_compat() ) {
    930931                return true;
     932        }
     933
     934        // look in parent / child theme for custom template
     935        if ( locate_template( array( 'register.php' ), false ) || locate_template( array( '/registration/register.php' ), false ) ) {
     936                return true;
     937        }
    931938
    932939        return false;
    933940}
  • bp-themes/bp-legacy/buddypress/members/activate.php

     
    66
    77                <?php if ( bp_account_was_activated() ) : ?>
    88
    9                         <h2 class="widgettitle"><?php _e( 'Account Activated', 'buddypress' ); ?></h2>
    10 
    119                        <?php do_action( 'bp_before_activate_content' ); ?>
    1210
    1311                        <?php if ( isset( $_GET['e'] ) ) : ?>
     
    1816
    1917                <?php else : ?>
    2018
    21                         <h3><?php _e( 'Activate your Account', 'buddypress' ); ?></h3>
    22 
    2319                        <?php do_action( 'bp_before_activate_content' ); ?>
    2420
    2521                        <p><?php _e( 'Please provide a valid activation key.', 'buddypress' ); ?></p>
  • bp-themes/bp-legacy/buddypress/members/register.php

     
    1717
    1818                <?php if ( 'request-details' == bp_get_current_signup_step() ) : ?>
    1919
    20                         <h2><?php _e( 'Create an Account', 'buddypress' ); ?></h2>
    21 
    2220                        <?php do_action( 'template_notices' ); ?>
    2321
    2422                        <p><?php _e( 'Registering for this site is easy, just fill in the fields below and we\'ll get a new account set up for you in no time.', 'buddypress' ); ?></p>
     
    246244
    247245                <?php if ( 'completed-confirmation' == bp_get_current_signup_step() ) : ?>
    248246
    249                         <h2><?php _e( 'Sign Up Complete!', 'buddypress' ); ?></h2>
    250 
    251247                        <?php do_action( 'template_notices' ); ?>
    252248                        <?php do_action( 'bp_before_registration_confirmed' ); ?>
    253249