signup->step = 'request-details'; if ( !bp_get_signup_allowed() ) { $bp->signup->step = 'registration-disabled'; // If the signup page is submitted, validate and save. } elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) { /** * Fires before the validation of a new signup. * * @since 2.0.0 */ do_action( 'bp_signup_pre_validate' ); // Check the base account details for problems. $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] ); // If there are errors with account details, set them for display. if ( !empty( $account_details['errors']->errors['user_name'] ) ) $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; if ( !empty( $account_details['errors']->errors['user_email'] ) ) $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; // Check that both password fields are filled in. if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) ) $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' ); // Check that the passwords match. if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] ) $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' ); if ( bp_signup_requires_privacy_policy_acceptance() && ! empty( $_POST['signup-privacy-policy-check'] ) && empty( $_POST['signup-privacy-policy-accept'] ) ) { $bp->signup->errors['signup_privacy_policy'] = __( 'You must indicate that you have read and agreed to the Privacy Policy.', 'buddypress' ); } $bp->signup->username = $_POST['signup_username']; $bp->signup->email = $_POST['signup_email']; // Now we've checked account details, we can check profile information. if ( bp_is_active( 'xprofile' ) ) { // Make sure hidden field is passed and populated. if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) { // Let's compact any profile field info into an array. $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); // Loop through the posted fields formatting any datebox values then validate the field. foreach ( (array) $profile_field_ids as $field_id ) { bp_xprofile_maybe_format_datebox_post_data( $field_id ); // Trim post fields. if ( isset( $_POST[ 'field_' . $field_id ] ) ) { if ( is_array( $_POST[ 'field_' . $field_id ] ) ) { $_POST[ 'field_' . $field_id ] = array_map( 'trim', $_POST[ 'field_' . $field_id ] ); } else { $_POST[ 'field_' . $field_id ] = trim( $_POST[ 'field_' . $field_id ] ); } } // Create errors for required fields without values. if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST[ 'field_' . $field_id ] ) && ! bp_current_user_can( 'bp_moderate' ) ) $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' ); } // This situation doesn't naturally occur so bounce to website root. } else { bp_core_redirect( bp_get_root_domain() ); } } // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled. if ( isset( $_POST['signup_with_blog'] ) ) { $active_signup = bp_core_get_root_option( 'registration' ); if ( 'blog' == $active_signup || 'all' == $active_signup ) { $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); // If there are errors with blog details, set them for display. if ( !empty( $blog_details['errors']->errors['blogname'] ) ) $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0]; if ( !empty( $blog_details['errors']->errors['blog_title'] ) ) $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0]; } } /** * Fires after the validation of a new signup. * * @since 1.1.0 */ do_action( 'bp_signup_validate' ); // Add any errors to the action for the field in the template for display. if ( !empty( $bp->signup->errors ) ) { foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) { /** * Filters the error message in the loop. * * @since 1.5.0 * * @param string $value Error message wrapped in html. */ add_action( 'bp_' . $fieldname . '_errors', function() use ( $error_message ) { echo apply_filters( 'bp_members_signup_error_message', "