Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2009 06:56:42 PM (17 years ago)
Author:
apeatling
Message:

Merging last few trunk changes and stripping all whitespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1/bp-core/bp-core-signup.php

    r2075 r2076  
    33function bp_core_screen_signup() {
    44        global $bp, $wpdb;
    5        
     5
    66        if ( $bp->current_component != BP_REGISTER_SLUG )
    77                return false;
    8                
     8
    99        /* If the user is logged in, redirect away from here */
    1010        if ( is_user_logged_in() )
    1111                bp_core_redirect( $bp->root_domain );
    12        
     12
    1313        /***
    1414         * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function
    … …  
    2121        if ( 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() )
    2222                bp_core_redirect( $bp->root_domain );
    23                
     23
    2424        $bp->signup->step = 'request-details';
    25        
     25
    2626        /* If the signup page is submitted, validate and save */
    2727        if ( isset( $_POST['signup_submit'] ) ) {
    28                
     28
    2929                /* Check the nonce */
    3030                check_admin_referer( 'bp_new_signup' );
    31                        
     31
    3232                require_once( ABSPATH . WPINC . '/registration.php' );
    33                
     33
    3434                /* Check the base account details for problems */
    3535                $account_details = wpmu_validate_user_signup( $_POST['signup_username'] , $_POST['signup_email'] );
    36                
     36
    3737                /* If there are errors with account details, set them for display */
    3838                if ( !empty( $account_details['errors']->errors['user_name'] ) )
    3939                        $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
    40                
     40
    4141                if ( !empty( $account_details['errors']->errors['user_email'] ) )
    4242                        $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
    43                
     43
    4444                /* Check that both password fields are filled in */
    4545                if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
    … …  
    5454
    5555                /* Loop through the posted fields formatting any datebox values then validate the field */
    56                 foreach ( (array) $profile_field_ids as $field_id ) {           
     56                foreach ( (array) $profile_field_ids as $field_id ) {
    5757                        if ( !isset( $_POST['field_' . $field_id] ) ) {
    5858                                if ( isset( $_POST['field_' . $field_id . '_day'] ) )
    5959                                        $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
    6060                        }
    61                        
     61
    6262                        if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
    6363                                $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
    … …  
    6767                if ( isset( $_POST['signup_with_blog'] ) ) {
    6868                        $active_signup = get_site_option( 'registration' );
    69                
     69
    7070                        if ( 'blog' == $active_signup || 'all' == $active_signup ) {
    7171                                $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
    72                                
     72
    7373                                /* If there are errors with blog details, set them for display */
    7474                                if ( !empty( $blog_details['errors']->errors['blogname'] ) )
    … …  
    8888                } else {
    8989                        $bp->signup->step = 'save-details';
    90                        
     90
    9191                        /* No errors! Let's register those deets. */
    9292                        $active_signup = get_site_option( 'registration' );
    93                        
     93
    9494                        if ( 'none' != $active_signup ) {
    95                                
     95
    9696                                /* Let's compact any profile field info into usermeta */
    9797                                $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    9898
    9999                                /* Loop through the posted fields formatting any datebox values then add to usermeta */
    100                                 foreach ( (array) $profile_field_ids as $field_id ) {           
     100                                foreach ( (array) $profile_field_ids as $field_id ) {
    101101                                        if ( !isset( $_POST['field_' . $field_id] ) ) {
    102102                                                if ( isset( $_POST['field_' . $field_id . '_day'] ) )
    103103                                                        $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
    104104                                        }
    105                        
     105
    106106                                        if ( !empty( $_POST['field_' . $field_id] ) )
    107107                                                $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
    108108                                }
    109                                
     109
    110110                                /* Store the profile field ID's in usermeta */
    111111                                $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
    112                                
     112
    113113                                /* Hash and store the password */
    114114                                $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
    115                                
     115
    116116                                /* If the user decided to create a blog, save those details to usermeta */
    117117                                if ( 'blog' == $active_signup || 'all' == $active_signup ) {
    118118                                        $usermeta['public'] = ( 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
    119119                                }
    120                                
     120
    121121                                $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
    122                                                                
     122
    123123                                /* Finally, sign up the user and/or blog*/
    124124                                if ( isset( $_POST['signup_with_blog'] ) )
    … …  
    126126                                else
    127127                                        wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta );
    128                                
     128
    129129                                $bp->signup->step = 'completed-confirmation';
    130130                        }
    … …  
    132132                        do_action( 'bp_complete_signup' );
    133133                }
    134        
     134
    135135        }
    136136
    … …  
    139139        /* If user has uploaded a new avatar */
    140140        if ( !empty( $_FILES ) ) {
    141                
     141
    142142                /* Check the nonce */
    143143                check_admin_referer( 'bp_avatar_upload' );
    144144
    145145                $bp->signup->step = 'completed-confirmation';
    146                
     146
    147147                /* Get the activation key */
    148148                if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) {
    … …  
    151151                        /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
    152152                        $bp->signup->avatar_dir = wp_hash( $bp->signup->key );
    153                        
    154                         /* Pass the file to the avatar upload handler */               
    155                         if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {           
     153
     154                        /* Pass the file to the avatar upload handler */
     155                        if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
    156156                                $bp->avatar_admin->step = 'crop-image';
    157157
    158158                                /* Make sure we include the jQuery jCrop file for image cropping */
    159159                                add_action( 'wp', 'bp_core_add_jquery_cropper' );
    160                         }                       
     160                        }
    161161                }
    162162        }
    163        
     163
    164164        /* If the image cropping is done, crop the image and save a full/thumb version */
    165165        if ( isset( $_POST['avatar-crop-submit'] ) ) {
    166                
     166
    167167                /* Check the nonce */
    168168                check_admin_referer( 'bp_avatar_cropstore' );
    169                                                
     169
    170170                /* Reset the avatar step so we can show the upload form again if needed */
    171171                $bp->signup->step = 'completed-confirmation';
    … …  
    178178
    179179        }
    180         bp_core_load_template( 'registration/register' );       
     180        bp_core_load_template( 'registration/register' );
    181181}
    182182add_action( 'wp', 'bp_core_screen_signup', 3 );
    … …  
    187187        if ( !$bp->signup->avatar_dir )
    188188                return false;
    189        
     189
    190190        $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
    191191        $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path );
    … …  
    193193
    194194        $newbdir = $newdir;
    195        
     195
    196196        if ( !file_exists( $newdir ) )
    197197                @wp_mkdir_p( $newdir );
    … …  
    201201        $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
    202202
    203         return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );       
     203        return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
    204204}
    205205
    … …  
    209209                return false;
    210210
    211         if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) ) 
     211        if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
    212212                wp_redirect( bp_root_domain() . BP_REGISTER_SLUG );
    213213}
Note: See TracChangeset for help on using the changeset viewer.