do_autoload ) { require dirname( __FILE__ ) . '/classes/class-bp-members-theme-compat.php'; require dirname( __FILE__ ) . '/classes/class-bp-registration-theme-compat.php'; } /** * Handle the display of the profile page by loading the correct template file. * * @since 1.5.0 */ function bp_members_screen_display_profile() { /** * Fires right before the loading of the Member profile screen template file. * * @since 1.5.0 */ do_action( 'bp_members_screen_display_profile' ); /** * Filters the template to load for the Member profile page screen. * * @since 1.5.0 * * @param string $template Path to the Member template to load. */ bp_core_load_template( apply_filters( 'bp_members_screen_display_profile', 'members/single/home' ) ); } /** * Handle the display of the members directory index. * * @since 1.5.0 */ function bp_members_screen_index() { if ( bp_is_members_directory() ) { bp_update_is_directory( true, 'members' ); /** * Fires right before the loading of the Member directory index screen template file. * * @since 1.5.0 */ do_action( 'bp_members_screen_index' ); /** * Filters the template to load for the Member directory page screen. * * @since 1.5.0 * * @param string $value Path to the member directory template to load. */ bp_core_load_template( apply_filters( 'bp_members_screen_index', 'members/index' ) ); } } add_action( 'bp_screens', 'bp_members_screen_index' ); /** * Handle the loading of the signup screen. * * @since 1.1.0 */ function bp_core_screen_signup() { $bp = buddypress(); if ( ! bp_is_current_component( 'register' ) || bp_current_action() ) return; // Not a directory. bp_update_is_directory( false, 'register' ); // If the user is logged in, redirect away from here. if ( is_user_logged_in() ) { $redirect_to = bp_is_component_front_page( 'register' ) ? bp_get_members_directory_permalink() : bp_get_root_domain(); /** * Filters the URL to redirect logged in users to when visiting registration page. * * @since 1.5.1 * * @param string $redirect_to URL to redirect user to. */ bp_core_redirect( apply_filters( 'bp_loggedin_register_page_redirect_to', $redirect_to ) ); return; } $bp->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' ); $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 ) { if ( !isset( $_POST['field_' . $field_id] ) ) { if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ) ); } // 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 ) { /* * The addslashes() and stripslashes() used to avoid create_function() * syntax errors when the $error_message contains quotes. */ /** * Filters the error message in the loop. * * @since 1.5.0 * * @param string $value Error message wrapped in html. */ add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "