bp_blogs_signup_blog( string $blogname = '', string $blog_title = '', string|WP_Error $errors = '' )

Output the input fields for the blog creation form.


Parameters Parameters

$blogname

(string) (Optional) The default blog name (path or domain).

Default value: ''

$blog_title

(string) (Optional) The default blog title.

Default value: ''

$errors

(string|WP_Error) (Optional) The WP_Error object returned by a previous submission attempt.

Default value: ''


Source Source

File: bp-blogs/bp-blogs-template.php

function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
	$current_site = get_current_site();

	if ( ! $blogname && ! $blog_title ) {
		$submitted_vars = bp_blogs_get_signup_form_submitted_vars();

		if ( array_filter( $submitted_vars ) ) {
			$blogname   = $submitted_vars['blogname'];
			$blog_title = $submitted_vars['blog_title'];
		}
	}
	?>

	<p>
		<?php
		// Blog name.
		if ( ! is_subdomain_install() ) {
			printf( '<label for="blogname">%s</label>', esc_html__( 'Site Name:', 'buddypress' ) );
		} else {
			printf( '<label for="blogname">%s</label>', esc_html__( 'Site Domain:', 'buddypress' ) );
		}

		if ( ! is_subdomain_install() ) {
			printf(
				'<span class="prefix_address">%1$s</span> <input name="blogname" type="text" id="blogname" value="%2$s" maxlength="63" style="width: auto!important" /><br />',
				esc_html( $current_site->domain . $current_site->path ),
				esc_attr( $blogname )
			);
		} else {
			printf(
				'<input name="blogname" type="text" id="blogname" value="%1$s" maxlength="63" style="width: auto!important" %2$s/> <span class="suffix_address">.%3$s</span><br />',
				esc_attr( $blogname ),
				bp_get_form_field_attributes( 'blogname' ),
				bp_signup_get_subdomain_base()
			);
		}
		if ( is_wp_error( $errors ) && $errors->get_error_message( 'blogname' ) ) {
			printf( '<div class="error">%s</div>', $errors->get_error_message( 'blogname' ) );
		}
		?>
	</p>

	<?php
	if ( ! is_user_logged_in() ) {
		$url = sprintf(
			/* translators: %s is the site domain and path. */
			__( 'domain.%s' , 'buddypress' ),
			$current_site->domain . $current_site->path
		);

		if ( ! is_subdomain_install() ) {
			$url = sprintf(
				/* translators: %s is the site domain and path. */
				__( '%sblogname' , 'buddypress'),
				$current_site->domain . $current_site->path
			);
		}

		printf(
			'<p>(<strong>%1$s.</strong> %2$s)</p>',
			sprintf(
				/* translators: %s is the site url. */
				esc_html__( 'Your address will be %s' , 'buddypress' ), $url
			),
			esc_html__( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!' , 'buddypress' )
		);
	}

	// Blog Title.
	?>
	<p>
		<label for="blog_title"><?php esc_html_e('Site Title:', 'buddypress') ?></label>
		<input name="blog_title" type="text" id="blog_title" value="<?php echo esc_html( $blog_title ); ?>" />

		<?php
		if ( is_wp_error( $errors ) && $errors->get_error_message( 'blog_title' ) ) {
			printf( '<div class="error">%s</div>', $errors->get_error_message( 'blog_title' ) );
		}
		?>
	</p>

	<fieldset class="create-site">

		<legend class="label"><?php esc_html_e( 'Privacy: I would like my site to appear in search engines, and in public listings around this network', 'buddypress' ) ?></legend>

		<p>
			<label class="checkbox" for="blog_public_on">
				<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php checked( ! isset( $_POST['blog_public'] ) || 1 === (int) $_POST['blog_public'] ); ?> />
				<strong><?php esc_html_e( 'Yes' , 'buddypress'); ?></strong>
			</label>
		</p>

		<p>
			<label class="checkbox" for="blog_public_off">
				<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php checked( isset( $_POST['blog_public'] ) && 0 === (int) $_POST['blog_public'] ); ?> />
				<strong><?php esc_html_e( 'No' , 'buddypress'); ?></strong>
			</label>
		</p>

	</fieldset>

	<?php

	/**
	 * Fires at the end of all of the default input fields for blog creation form.
	 *
	 * @since 1.0.0
	 *
	 * @param WP_Error $errors WP_Error object if any present.
	 */
	do_action( 'signup_blogform', $errors );
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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