show_user_form

函数
show_user_form ( $user_name = '', $user_email = '', $errors = '' )
参数
  • (string) $user_name The entered username.
    Required:
    Default: (empty)
  • (string) $user_email The entered email address.
    Required:
    Default: (empty)
  • (WP_Error|string) $errors A WP_Error object containing existing errors. Defaults to empty string.
    Required:
    Default: (empty)
定义位置
相关方法
show_blog_formvalidate_user_formget_search_forminstall_search_formis_user_admin
引入
-
弃用
-

show_user_form: 这个函数用来显示在WordPress多站点安装中创建一个新用户的表单: 这个函数不需要任何参数。

显示新用户账户注册表的字段。

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

	// Username.
	echo '<label for="user_name">' . __( 'Username:' ) . '</label>';
	$errmsg_username      = $errors->get_error_message( 'user_name' );
	$errmsg_username_aria = '';
	if ( $errmsg_username ) {
		$errmsg_username_aria = 'wp-signup-username-error ';
		echo '<p class="error" id="wp-signup-username-error">' . $errmsg_username . '</p>';
	}
	?>
	<input name="user_name" type="text" id="user_name" value="<?php echo esc_attr( $user_name ); ?>" autocapitalize="none" autocorrect="off" maxlength="60" autocomplete="username" required="required" aria-describedby="<?php echo $errmsg_username_aria; ?>wp-signup-username-description" />
	<p id="wp-signup-username-description"><?php _e( '(Must be at least 4 characters, lowercase letters and numbers only.)' ); ?></p>

	<?php
	// Email address.
	echo '<label for="user_email">' . __( 'Email&nbsp;Address:' ) . '</label>';
	$errmsg_email      = $errors->get_error_message( 'user_email' );
	$errmsg_email_aria = '';
	if ( $errmsg_email ) {
		$errmsg_email_aria = 'wp-signup-email-error ';
		echo '<p class="error" id="wp-signup-email-error">' . $errmsg_email . '</p>';
	}
	?>
	<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" autocomplete="email" required="required" aria-describedby="<?php echo $errmsg_email_aria; ?>wp-signup-email-description" />
	<p id="wp-signup-email-description"><?php _e( 'Your registration email is sent to this address. (Double-check your email address before continuing.)' ); ?></p>

	<?php
	// Extra fields.
	$errmsg_generic = $errors->get_error_message( 'generic' );
	if ( $errmsg_generic ) {
		echo '<p class="error" id="wp-signup-generic-error">' . $errmsg_generic . '</p>';
	}
	/**
	 * Fires at the end of the new user account registration form.
	 *
	 * @since 3.0.0
	 *
	 * @param WP_Error $errors A WP_Error object containing 'user_name' or 'user_email' errors.
	 */
	do_action( 'signup_extra_fields', $errors );
}

常见问题

FAQs
查看更多 >