Skip to:
Content
Pages
Categories
Search
Top
Bottom

Removing name field from registration


  • froster2
    Participant

    @froster2

    This is a quick fix until https://buddypress.trac.wordpress.org/ticket/5373 is resolved and should only be used with caution as it edits core files. Future updates should be changed file by file. Not recommended for everyone!

    Remove following code from buddypress/bp-members/bp-members-screens.php Line 129 – 154

    		// 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() );
    			}
    		}

    Remove following code from buddypress/bp-members/bp-members-screens.php Line 204 – 231

    				// Make sure the extended profiles module is enabled.
    				if ( bp_is_active( 'xprofile' ) ) {
    					// Let's compact any profile field info into usermeta.
    					$profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    
    					// 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().
    					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'] ) ) {
    								// Concatenate the values.
    								$date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
    
    								// Turn the concatenated value into a timestamp.
    								$_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
    							}
    						}
    
    						if ( !empty( $_POST['field_' . $field_id] ) )
    							$usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
    
    						if ( !empty( $_POST['field_' . $field_id . '_visibility'] ) )
    							$usermeta['field_' . $field_id . '_visibility'] = $_POST['field_' . $field_id . '_visibility'];
    					}
    
    					// Store the profile field ID's in usermeta.
    					$usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
    				}

    Remove following code from buddypress/bp-templates/bp-legacy/buddypress/members/register.php Line 143 – 247

    			<?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
    				<?php
    
    				/**
    				 * Fires before the display of member registration xprofile fields.
    				 *
    				 * @since 1.2.4
    				 */
    				do_action( 'bp_before_signup_profile_fields' ); ?>
    
    				<div class="register-section" id="profile-details-section">
    
    					<h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4>
    
    					<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    					<?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
    					<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
    						<div<?php bp_field_css_class( 'editfield' ); ?>>
    
    							<?php
    							$field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
    							$field_type->edit_field_html();
    
    							/**
    							 * Fires before the display of the visibility options for xprofile fields.
    							 *
    							 * @since 1.7.0
    							 */
    							do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
    
    							if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
    								<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    									<?php
    									printf(
    										__( 'This field can be seen by: %s', 'buddypress' ),
    										'<span class="current-visibility-level">' . bp_get_the_profile_field_visibility_level_label() . '</span>'
    									);
    									?>
    									<a href="#" class="visibility-toggle-link"><?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?></a>
    								</p>
    
    								<div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
    									<fieldset>
    										<legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
    
    										<?php bp_profile_visibility_radio_buttons() ?>
    
    									</fieldset>
    									<a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
    
    								</div>
    							<?php else : ?>
    								<p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    									<?php
    									printf(
    										__( 'This field can be seen by: %s', 'buddypress' ),
    										'<span class="current-visibility-level">' . bp_get_the_profile_field_visibility_level_label() . '</span>'
    									);
    									?>
    								</p>
    							<?php endif ?>
    
    							<?php
    
    							/**
    							 * Fires after the display of the visibility options for xprofile fields.
    							 *
    							 * @since 1.1.0
    							 */
    							do_action( 'bp_custom_profile_edit_fields' ); ?>
    
    							<p class="description"><?php bp_the_profile_field_description(); ?></p>
    
    						</div>
    
    					<?php endwhile; ?>
    
    					<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
    
    					<?php endwhile; endif; endif; ?>
    
    					<?php
    
    					/**
    					 * Fires and displays any extra member registration xprofile fields.
    					 *
    					 * @since 1.9.0
    					 */
    					do_action( 'bp_signup_profile_fields' ); ?>
    
    				</div><!-- #profile-details-section -->
    
    				<?php
    
    				/**
    				 * Fires after the display of member registration xprofile fields.
    				 *
    				 * @since 1.1.0
    				 */
    				do_action( 'bp_after_signup_profile_fields' ); ?>
    
    			<?php endif; ?>

    Remove following code from buddypress/bp-themes/bp-default/registration/register.php Line 61 – 207

    				<?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
    					<?php do_action( 'bp_before_signup_profile_fields' ); ?>
    
    					<div class="register-section" id="profile-details-section">
    
    						<h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4>
    
    						<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    						<?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
    						<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
    							<div class="editfield">
    
    								<?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>
    
    									<label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
    									<?php do_action( bp_get_the_profile_field_errors_action() ); ?>
    									<input type="text" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" value="<?php bp_the_profile_field_edit_value(); ?>" />
    
    								<?php endif; ?>
    
    								<?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?>
    
    									<label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
    									<?php do_action( bp_get_the_profile_field_errors_action() ); ?>
    									<textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_edit_value(); ?></textarea>
    
    								<?php endif; ?>
    
    								<?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?>
    
    									<label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
    									<?php do_action( bp_get_the_profile_field_errors_action() ); ?>
    									<select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>">
    										<?php bp_the_profile_field_options(); ?>
    									</select>
    
    								<?php endif; ?>
    
    								<?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?>
    
    									<label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
    									<?php do_action( bp_get_the_profile_field_errors_action() ); ?>
    									<select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" multiple="multiple">
    										<?php bp_the_profile_field_options(); ?>
    									</select>
    
    								<?php endif; ?>
    
    								<?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?>
    
    									<div class="radio">
    										<span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span>
    
    										<?php do_action( bp_get_the_profile_field_errors_action() ); ?>
    										<?php bp_the_profile_field_options(); ?>
    
    										<?php if ( !bp_get_the_profile_field_is_required() ) : ?>
    											<a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a>
    										<?php endif; ?>
    									</div>
    
    								<?php endif; ?>
    
    								<?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?>
    
    									<div class="checkbox">
    										<span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span>
    
    										<?php do_action( bp_get_the_profile_field_errors_action() ); ?>
    										<?php bp_the_profile_field_options(); ?>
    									</div>
    
    								<?php endif; ?>
    
    								<?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?>
    
    									<div class="datebox">
    										<label for="<?php bp_the_profile_field_input_name(); ?>_day"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
    										<?php do_action( bp_get_the_profile_field_errors_action() ); ?>
    
    										<select name="<?php bp_the_profile_field_input_name(); ?>_day" id="<?php bp_the_profile_field_input_name(); ?>_day">
    											<?php bp_the_profile_field_options( 'type=day' ); ?>
    										</select>
    
    										<select name="<?php bp_the_profile_field_input_name(); ?>_month" id="<?php bp_the_profile_field_input_name(); ?>_month">
    											<?php bp_the_profile_field_options( 'type=month' ); ?>
    										</select>
    
    										<select name="<?php bp_the_profile_field_input_name(); ?>_year" id="<?php bp_the_profile_field_input_name(); ?>_year">
    											<?php bp_the_profile_field_options( 'type=year' ); ?>
    										</select>
    									</div>
    
    								<?php endif; ?>
    
    								<?php if ( 'url' == bp_get_the_profile_field_type() ) : ?>
    
    									<label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label>
    									<input type="text" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" value="<?php bp_the_profile_field_edit_value(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>/>
    
    								<?php endif; ?>
    
    								<?php do_action( 'bp_custom_profile_edit_fields_pre_visibility' ); ?>
    
    								<?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
    									<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    										<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?></a>
    									</p>
    
    									<div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
    										<fieldset>
    											<legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
    
    											<?php bp_profile_visibility_radio_buttons() ?>
    
    										</fieldset>
    										<a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
    
    									</div>
    								<?php else : ?>
    									<p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    										<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
    									</p>
    								<?php endif ?>
    
    								<?php do_action( 'bp_custom_profile_edit_fields' ); ?>
    
    								<p class="description"><?php bp_the_profile_field_description(); ?></p>
    
    							</div>
    
    						<?php endwhile; ?>
    
    						<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" />
    
    						<?php endwhile; endif; endif; ?>
    
    						<?php do_action( 'bp_signup_profile_fields' ); ?>
    
    					</div><!-- #profile-details-section -->
    
    					<?php do_action( 'bp_after_signup_profile_fields' ); ?>
    
    				<?php endif; ?>
  • The topic ‘Removing name field from registration’ is closed to new replies.
Skip to toolbar