Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2015 01:58:52 AM (9 years ago)
Author:
tw2113
Message:

More documentation cleanup for the Members component.

See #6402.

File:
1 edited

Legend:

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

    r10276 r10322  
    6969        return;
    7070
    71     // Not a directory
     71    // Not a directory.
    7272    bp_update_is_directory( false, 'register' );
    7373
    74     // If the user is logged in, redirect away from here
     74    // If the user is logged in, redirect away from here.
    7575    if ( is_user_logged_in() ) {
    7676
     
    9696        $bp->signup->step = 'registration-disabled';
    9797
    98     // If the signup page is submitted, validate and save
     98    // If the signup page is submitted, validate and save.
    9999    } elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) {
    100100
     
    106106        do_action( 'bp_signup_pre_validate' );
    107107
    108         // Check the base account details for problems
     108        // Check the base account details for problems.
    109109        $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
    110110
    111         // If there are errors with account details, set them for display
     111        // If there are errors with account details, set them for display.
    112112        if ( !empty( $account_details['errors']->errors['user_name'] ) )
    113113            $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
     
    116116            $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
    117117
    118         // Check that both password fields are filled in
     118        // Check that both password fields are filled in.
    119119        if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
    120120            $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' );
    121121
    122         // Check that the passwords match
     122        // Check that the passwords match.
    123123        if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] )
    124124            $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' );
     
    127127        $bp->signup->email = $_POST['signup_email'];
    128128
    129         // Now we've checked account details, we can check profile information
     129        // Now we've checked account details, we can check profile information.
    130130        if ( bp_is_active( 'xprofile' ) ) {
    131131
    132             // Make sure hidden field is passed and populated
     132            // Make sure hidden field is passed and populated.
    133133            if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) {
    134134
    135                 // Let's compact any profile field info into an array
     135                // Let's compact any profile field info into an array.
    136136                $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    137137
    138                 // Loop through the posted fields formatting any datebox values then validate the field
     138                // Loop through the posted fields formatting any datebox values then validate the field.
    139139                foreach ( (array) $profile_field_ids as $field_id ) {
    140140                    if ( !isset( $_POST['field_' . $field_id] ) ) {
     
    143143                    }
    144144
    145                     // Create errors for required fields without values
     145                    // Create errors for required fields without values.
    146146                    if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST[ 'field_' . $field_id ] ) && ! bp_current_user_can( 'bp_moderate' ) )
    147147                        $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
    148148                }
    149149
    150             // This situation doesn't naturally occur so bounce to website root
     150            // This situation doesn't naturally occur so bounce to website root.
    151151            } else {
    152152                bp_core_redirect( bp_get_root_domain() );
     
    154154        }
    155155
    156         // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled
     156        // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled.
    157157        if ( isset( $_POST['signup_with_blog'] ) ) {
    158158            $active_signup = bp_core_get_root_option( 'registration' );
     
    161161                $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
    162162
    163                 // If there are errors with blog details, set them for display
     163                // If there are errors with blog details, set them for display.
    164164                if ( !empty( $blog_details['errors']->errors['blogname'] ) )
    165165                    $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
     
    180180        if ( !empty( $bp->signup->errors ) ) {
    181181            foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) {
    182                 // addslashes() and stripslashes() to avoid create_function()
    183                 // syntax errors when the $error_message contains quotes
     182                /*
     183                 * The addslashes() and stripslashes() used to avoid create_function()
     184                 * syntax errors when the $error_message contains quotes.
     185                 */
    184186
    185187                /**
     
    200202            if ( 'none' != $active_signup ) {
    201203
    202                 // Make sure the extended profiles module is enabled
     204                // Make sure the extended profiles module is enabled.
    203205                if ( bp_is_active( 'xprofile' ) ) {
    204                     // Let's compact any profile field info into usermeta
     206                    // Let's compact any profile field info into usermeta.
    205207                    $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    206208
    207                     // 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()
     209                    // 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().
    208210                    foreach ( (array) $profile_field_ids as $field_id ) {
    209211                        if ( ! isset( $_POST['field_' . $field_id] ) ) {
    210212
    211213                            if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) {
    212                                 // Concatenate the values
     214                                // Concatenate the values.
    213215                                $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
    214216
    215                                 // Turn the concatenated value into a timestamp
     217                                // Turn the concatenated value into a timestamp.
    216218                                $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
    217219                            }
     
    225227                    }
    226228
    227                     // Store the profile field ID's in usermeta
     229                    // Store the profile field ID's in usermeta.
    228230                    $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
    229231                }
    230232
    231                 // Hash and store the password
     233                // Hash and store the password.
    232234                $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
    233235
    234                 // If the user decided to create a blog, save those details to usermeta
     236                // If the user decided to create a blog, save those details to usermeta.
    235237                if ( 'blog' == $active_signup || 'all' == $active_signup )
    236238                    $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
     
    245247                $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
    246248
    247                 // Finally, sign up the user and/or blog
     249                // Finally, sign up the user and/or blog.
    248250                if ( isset( $_POST['signup_with_blog'] ) && is_multisite() )
    249251                    $wp_user_id = bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
     
    294296function bp_core_screen_activation() {
    295297
    296     // Bail if not viewing the activation page
     298    // Bail if not viewing the activation page.
    297299    if ( ! bp_is_current_component( 'activate' ) ) {
    298300        return false;
    299301    }
    300302
    301     // If the user is already logged in, redirect away from here
     303    // If the user is already logged in, redirect away from here.
    302304    if ( is_user_logged_in() ) {
    303305
     
    308310            : bp_get_root_domain();
    309311
    310         // Trailing slash it, as we expect these URL's to be
     312        // Trailing slash it, as we expect these URL's to be.
    311313        $redirect_to = trailingslashit( $redirect_to );
    312314
     
    320322        $redirect_to = apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to );
    321323
    322         // Redirect away from the activation page
     324        // Redirect away from the activation page.
    323325        bp_core_redirect( $redirect_to );
    324326    }
    325327
    326     // grab the key (the old way)
     328    // Grab the key (the old way).
    327329    $key = isset( $_GET['key'] ) ? $_GET['key'] : '';
    328330
    329     // grab the key (the new way)
     331    // Grab the key (the new way).
    330332    if ( empty( $key ) ) {
    331333        $key = bp_current_action();
    332334    }
    333335
    334     // Get BuddyPress
     336    // Get BuddyPress.
    335337    $bp = buddypress();
    336338
    337     // we've got a key; let's attempt to activate the signup
     339    // We've got a key; let's attempt to activate the signup.
    338340    if ( ! empty( $key ) ) {
    339341
     
    348350        $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
    349351
    350         // If there were errors, add a message and redirect
     352        // If there were errors, add a message and redirect.
    351353        if ( ! empty( $user->errors ) ) {
    352354            bp_core_add_message( $user->get_error_message(), 'error' );
     
    357359
    358360        // Check if the signup avatar folder exists. If it does, move the folder to
    359         // the BP user avatars directory
     361        // the BP user avatars directory.
    360362        if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) {
    361363            @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
     
    405407    public function is_members() {
    406408
    407         // Bail if not looking at the members component or a user's page
     409        // Bail if not looking at the members component or a user's page.
    408410        if ( ! bp_is_members_component() && ! bp_is_user() ) {
    409411            return;
    410412        }
    411413
    412         // Members Directory
     414        // Members Directory.
    413415        if ( ! bp_current_action() && ! bp_current_item() ) {
    414416            bp_update_is_directory( true, 'members' );
     
    425427            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
    426428
    427         // User page
     429        // User page.
    428430        } elseif ( bp_is_user() ) {
    429431
     
    459461     *
    460462     * @param array $templates The templates from bp_get_theme_compat_templates().
    461      *
    462463     * @return array $templates Array of custom templates to look for.
    463464     */
    464465    public function directory_template_hierarchy( $templates = array() ) {
    465466
    466         // Set up the template hierarchy
     467        // Set up the template hierarchy.
    467468        $new_templates = array();
    468469        if ( '' !== bp_get_current_member_type() ) {
     
    481482
    482483        // Merge new templates with existing stack
    483         // @see bp_get_theme_compat_templates()
     484        // @see bp_get_theme_compat_templates().
    484485        $templates = array_merge( (array) $new_templates, $templates );
    485486
     
    527528     * @param string $templates The templates from
    528529     *                          bp_get_theme_compat_templates().
    529      *
    530530     * @return array $templates Array of custom templates to look for.
    531531     */
    532532    public function single_template_hierarchy( $templates ) {
    533         // Setup some variables we're going to reference in our custom templates
     533        // Setup some variables we're going to reference in our custom templates.
    534534        $user_nicename = buddypress()->displayed_user->userdata->user_nicename;
    535535
     
    550550
    551551        // Merge new templates with existing stack
    552         // @see bp_get_theme_compat_templates()
     552        // @see bp_get_theme_compat_templates().
    553553        $templates = array_merge( (array) $new_templates, $templates );
    554554
     
    612612    public function is_registration() {
    613613
    614         // Bail if not looking at the registration or activation page
     614        // Bail if not looking at the registration or activation page.
    615615        if ( ! bp_is_register_page() && ! bp_is_activation_page() ) {
    616616            return;
    617617        }
    618618
    619         // Not a directory
     619        // Not a directory.
    620620        bp_update_is_directory( false, 'register' );
    621621
    622         // Setup actions
     622        // Setup actions.
    623623        add_filter( 'bp_get_buddypress_template',                array( $this, 'template_hierarchy' ) );
    624624        add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post'    ) );
     
    637637     *
    638638     * @param string $templates The templates from bp_get_theme_compat_templates().
    639      *
    640639     * @return array $templates Array of custom templates to look for.
    641640     */
     
    658657
    659658        // Merge new templates with existing stack
    660         // @see bp_get_theme_compat_templates()
     659        // @see bp_get_theme_compat_templates().
    661660        $templates = array_merge( (array) $new_templates, $templates );
    662661
     
    670669     */
    671670    public function dummy_post() {
    672         // Registration page
     671        // Registration page.
    673672        if ( bp_is_register_page() ) {
    674673            $title = __( 'Create an Account', 'buddypress' );
     
    678677            }
    679678
    680         // Activation page
     679        // Activation page.
    681680        } else {
    682681            $title = __( 'Activate Your Account', 'buddypress' );
Note: See TracChangeset for help on using the changeset viewer.