Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/13/2012 07:00:54 AM (13 years ago)
Author:
r-a-y
Message:

Theme Compat:

  • Introduce BP_Registration_Theme_Compat class - Adds registration / activation template support to theme compat.
  • Remove headers in bp-legacy register.php and activate.php template files as this is now handled by the_title().
  • Fix notice during signup when the XProfile component was disabled
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-screens.php

    r6397 r6401  
    161161            if ( 'none' != $active_signup ) {
    162162
    163                 // Let's compact any profile field info into usermeta
    164                 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    165 
    166                 // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile()
    167                 foreach ( (array) $profile_field_ids as $field_id ) {
    168                     if ( ! isset( $_POST['field_' . $field_id] ) ) {
    169 
    170                         if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) {
    171                             // Concatenate the values
    172                             $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
    173 
    174                             // Turn the concatenated value into a timestamp
    175                             $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
     163                // Make sure the extended profiles module is enabled
     164                if ( bp_is_active( 'xprofile' ) ) {
     165                    // Let's compact any profile field info into usermeta
     166                    $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
     167
     168                    // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile()
     169                    foreach ( (array) $profile_field_ids as $field_id ) {
     170                        if ( ! isset( $_POST['field_' . $field_id] ) ) {
     171
     172                            if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) {
     173                                // Concatenate the values
     174                                $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
     175
     176                                // Turn the concatenated value into a timestamp
     177                                $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
     178                            }
    176179                        }
     180
     181                        if ( !empty( $_POST['field_' . $field_id] ) )
     182                            $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
     183
     184                        if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) )
     185                            $usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
    177186                    }
    178187
    179                     if ( !empty( $_POST['field_' . $field_id] ) )
    180                         $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
    181                    
    182                     if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) )
    183                         $usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
     188                    // Store the profile field ID's in usermeta
     189                    $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
    184190                }
    185 
    186                 // Store the profile field ID's in usermeta
    187                 $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
    188191
    189192                // Hash and store the password
     
    204207                if ( is_wp_error( $wp_user_id ) ) {
    205208                    $bp->signup->step = 'request-details';
    206                     bp_core_add_message( $wp_user_id->get_error_message(), 'error' ); 
     209                    bp_core_add_message( $wp_user_id->get_error_message(), 'error' );
    207210                } else {
    208211                    $bp->signup->step = 'completed-confirmation';
     
    371374}
    372375new BP_Members_Theme_Compat();
     376
     377/**
     378 * The main theme compat class for BuddyPress Registration.
     379 *
     380 * This class sets up the necessary theme compatability actions to safely output
     381 * registration template parts to the_title and the_content areas of a theme.
     382 *
     383 * @since BuddyPress (1.7)
     384 */
     385class BP_Registration_Theme_Compat {
     386
     387    /**
     388     * Setup the groups component theme compatibility
     389     *
     390     * @since BuddyPress (1.7)
     391     */
     392    public function __construct() {
     393        add_action( 'bp_setup_theme_compat', array( $this, 'is_registration' ) );
     394    }
     395
     396    /**
     397     * Are we looking at either the registration or activation pages?
     398     *
     399     * @since BuddyPress (1.7)
     400     */
     401    public function is_registration() {
     402
     403        // Bail if not looking at the registration or activation page
     404        if ( ! bp_is_register_page() && ! bp_is_activation_page() ) {
     405            return;
     406        }
     407
     408        // Not a directory
     409        bp_update_is_directory( false, 'register' );
     410
     411        // Setup actions
     412        add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post'    ) );
     413        add_filter( 'bp_replace_the_content',                    array( $this, 'dummy_content' ) );
     414    }
     415
     416    /** Template ***********************************************************/
     417
     418    /**
     419     * Update the global $post with dummy data
     420     *
     421     * @since BuddyPress (1.7)
     422     */
     423    public function dummy_post() {
     424        // Registration page
     425        if ( bp_is_register_page() ) {
     426            $title = __( 'Create an Account', 'buddypress' );
     427
     428            if ( 'completed-confirmation' == bp_get_current_signup_step() ) {
     429                $title = __( 'Sign Up Complete!', 'buddypress' );
     430            }
     431
     432        // Activation page
     433        } else {
     434            $title = __( 'Activate your Account', 'buddypress' );
     435
     436            if ( bp_account_was_activated() ) {
     437                $title = __( 'Account Activated', 'buddypress' );
     438            }
     439        }
     440
     441        $post_type = bp_is_register_page() ? 'bp_register' : 'bp_activate';
     442
     443        bp_theme_compat_reset_post( array(
     444            'ID'             => 0,
     445            'post_title'     => $title,
     446            'post_author'    => 0,
     447            'post_date'      => 0,
     448            'post_content'   => '',
     449            'post_type'      => $post_type,
     450            'post_status'    => 'publish',
     451            'is_archive'     => true,
     452            'comment_status' => 'closed'
     453        ) );
     454    }
     455
     456    /**
     457     * Filter the_content with either the register or activate templates.
     458     *
     459     * @since BuddyPress (1.7)
     460     */
     461    public function dummy_content() {
     462        if ( bp_is_register_page() ) {
     463            bp_buffer_template_part( 'members/register' );
     464        } else {
     465            bp_buffer_template_part( 'members/activate' );
     466        }
     467    }
     468}
     469new BP_Registration_Theme_Compat();
Note: See TracChangeset for help on using the changeset viewer.