bp_nouveau_signup_form( string $section = 'account_details' )

Output the signup form for the requested section


Parameters Parameters

$section

(string) (Optional) The section of fields to get 'account_details' or 'blog_details'. Default: 'account_details'.

Default value: 'account_details'


Source Source

File: bp-templates/bp-nouveau/includes/template-tags.php

function bp_nouveau_signup_form( $section = 'account_details' ) {
	$fields = bp_nouveau_get_signup_fields( $section );
	if ( ! $fields ) {
		return;
	}

	foreach ( $fields as $name => $attributes ) {
		if ( 'signup_password' === $name ) {
			?>
			<label for="pass1"><?php esc_html_e( 'Choose a Password (required)', 'buddypress' ); ?></label>
			<div class="user-pass1-wrap">
				<div class="wp-pwd">
					<div class="password-input-wrapper">
						<input type="password" data-reveal="1" name="signup_password" id="pass1" class="password-entry" size="24" value="" <?php bp_form_field_attributes( 'password', array( 'data-pw' => wp_generate_password( 12 ), 'aria-describedby' => 'pass-strength-result' ) ); ?> />
						<button type="button" class="button wp-hide-pw">
							<span class="dashicons dashicons-hidden" aria-hidden="true"></span>
						</button>
					</div>
					<div id="pass-strength-result" aria-live="polite"><?php esc_html_e( 'Strength indicator', 'buddypress' ); ?></div>
				</div>
				<div class="pw-weak">
					<label>
						<input type="checkbox" name="pw_weak" class="pw-checkbox" />
						<?php esc_html_e( 'Confirm use of weak password', 'buddypress' ); ?>
					</label>
				</div>
			</div>
			<?php
		} elseif ( 'signup_password_confirm' === $name ) {
			?>
			<p class="user-pass2-wrap">
				<label for="pass2"><?php esc_html_e( 'Confirm new password', 'buddypress' ); ?></label><br />
				<input type="password" name="signup_password_confirm" id="pass2" class="password-entry-confirm" size="24" value="" <?php bp_form_field_attributes( 'password' ); ?> />
			</p>

			<p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
			<?php
		} else {
			list( $label, $required, $value, $attribute_type, $type, $class ) = array_values( $attributes );

			// Text fields are using strings, radios are using their inputs
			$label_output = '<label for="%1$s">%2$s</label>';
			$id           = $name;
			$classes      = '';

			if ( $required ) {
				/* translators: Do not translate placeholders. 2 = form field name, 3 = "(required)". */
				$label_output = __( '<label for="%1$s">%2$s %3$s</label>', 'buddypress' );
			}

			// Output the label for regular fields
			if ( 'radio' !== $type ) {
				if ( $required ) {
					printf( $label_output, esc_attr( $name ), esc_html( $label ), __( '(required)', 'buddypress' ) );
				} else {
					printf( $label_output, esc_attr( $name ), esc_html( $label ) );
				}

				if ( ! empty( $value ) && is_callable( $value ) ) {
					$value = call_user_func( $value );
				}

			// Handle the specific case of Site's privacy differently
			} elseif ( 'signup_blog_privacy_private' !== $name ) {
				?>
					<span class="label">
						<?php esc_html_e( 'I would like my site to appear in search engines, and in public listings around this network.', 'buddypress' ); ?>
					</span>
				<?php
			}

			// Set the additional attributes
			if ( $attribute_type ) {
				$existing_attributes = array();

				if ( ! empty( $required ) ) {
					$existing_attributes = array( 'aria-required' => 'true' );

					/**
					 * The blog section is hidden, so let's avoid a browser warning
					 * and deal with the Blog section in Javascript.
					 */
					if ( $section !== 'blog_details' ) {
						$existing_attributes['required'] = 'required';
					}
				}

				$attribute_type = ' ' . bp_get_form_field_attributes( $attribute_type, $existing_attributes );
			}

			// Specific case for Site's privacy
			if ( 'signup_blog_privacy_public' === $name || 'signup_blog_privacy_private' === $name ) {
				$name      = 'signup_blog_privacy';
				$submitted = bp_get_signup_blog_privacy_value();

				if ( ! $submitted ) {
					$submitted = 'public';
				}

				$attribute_type = ' ' . checked( $value, $submitted, false );
			}

			// Do not run function to display errors for the private radio.
			if ( 'private' !== $value ) {

				/**
				 * Fetch & display any BP member registration field errors.
				 *
				 * Passes BP signup errors to Nouveau's template function to
				 * render suitable markup for error string.
				 */
				if ( isset( buddypress()->signup->errors[ $name ] ) ) {
					nouveau_error_template( buddypress()->signup->errors[ $name ] );
					$invalid = 'invalid';
				}
			}

			if ( isset( $invalid ) && isset( buddypress()->signup->errors[ $name ] ) ) {
				if ( ! empty( $class ) ) {
					$class = $class . ' ' . $invalid;
				} else {
					$class = $invalid;
				}
			}

			if ( $class ) {
				$class = sprintf(
					' class="%s"',
					esc_attr( join( ' ', array_map( 'sanitize_html_class', explode( ' ', $class ) ) ) )
				);
			}

			// Set the input.
			$field_output = sprintf(
				'<input type="%1$s" name="%2$s" id="%3$s" %4$s value="%5$s" %6$s />',
				esc_attr( $type ),
				esc_attr( $name ),
				esc_attr( $id ),
				$class,  // Constructed safely above.
				esc_attr( $value ),
				$attribute_type // Constructed safely above.
			);

			// Not a radio, let's output the field
			if ( 'radio' !== $type ) {
				if ( 'signup_blog_url' !== $name ) {
					print( $field_output );  // Constructed safely above.

				// If it's the signup blog url, it's specific to Multisite config.
				} elseif ( is_subdomain_install() ) {
					// Constructed safely above.
					printf(
						'%1$s %2$s . %3$s',
						is_ssl() ? 'https://' : 'http://',
						$field_output,
						bp_signup_get_subdomain_base()
					);

				// Subfolders!
				} else {
					printf(
						'%1$s %2$s',
						home_url( '/' ),
						$field_output  // Constructed safely above.
					);
				}

			// It's a radio, let's output the field inside the label
			} else {
				// $label_output and $field_output are constructed safely above.
				printf( $label_output, esc_attr( $name ), $field_output . ' ' . esc_html( $label ) );
			}
		}
	}

	/**
	 * Fires and displays any extra member registration details fields.
	 *
	 * This is a variable hook that depends on the current section.
	 *
	 * @since 1.9.0
	 */
	do_action( "bp_{$section}_fields" );
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.