signup_blog

函数
signup_blog ( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' )
参数
  • (string) $user_name The username.
    Required:
    Default: (empty)
  • (string) $user_email The user's email address.
    Required:
    Default: (empty)
  • (string) $blogname The site name.
    Required:
    Default: (empty)
  • (string) $blog_title The site title.
    Required:
    Default: (empty)
  • (WP_Error|string) $errors A WP_Error object containing existing errors. Defaults to empty string.
    Required:
    Default: (empty)
定义位置
相关方法
wpmu_signup_blogsignup_another_bloginsert_blogsignup_userinstall_blog
引入
-
弃用
-

signup_blog: 这个函数用来在一个WordPress多站点安装上创建一个新的博客。它需要一个参数–$domain–这是新博客的域名。

显示一个用户或访客注册新网站的表格。

function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
	if ( ! is_wp_error( $errors ) ) {
		$errors = new WP_Error();
	}

	$signup_blog_defaults = array(
		'user_name'  => $user_name,
		'user_email' => $user_email,
		'blogname'   => $blogname,
		'blog_title' => $blog_title,
		'errors'     => $errors,
	);

	/**
	 * Filters the default site creation variables for the site sign-up form.
	 *
	 * @since 3.0.0
	 *
	 * @param array $signup_blog_defaults {
	 *     An array of default site creation variables.
	 *
	 *     @type string   $user_name  The user username.
	 *     @type string   $user_email The user email address.
	 *     @type string   $blogname   The blogname.
	 *     @type string   $blog_title The title of the site.
	 *     @type WP_Error $errors     A WP_Error object with possible errors relevant to new site creation variables.
	 * }
	 */
	$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );

	$user_name  = $filtered_results['user_name'];
	$user_email = $filtered_results['user_email'];
	$blogname   = $filtered_results['blogname'];
	$blog_title = $filtered_results['blog_title'];
	$errors     = $filtered_results['errors'];

	if ( empty( $blogname ) ) {
		$blogname = $user_name;
	}
	?>
	<form id="setupform" method="post" action="wp-signup.php">
		<input type="hidden" name="stage" value="validate-blog-signup" />
		<input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" />
		<input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" />
		<?php
		/** This action is documented in wp-signup.php */
		do_action( 'signup_hidden_fields', 'validate-site' );
		?>
		<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Sign up' ); ?>" /></p>
	</form>
	<?php
}

常见问题

FAQs
查看更多 >