wp/wp-admin/network/user-new.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    25 );
    25 );
    26 
    26 
    27 get_current_screen()->set_help_sidebar(
    27 get_current_screen()->set_help_sidebar(
    28 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    28 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    29 	'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Users_Screen">Documentation on Network Users</a>' ) . '</p>' .
    29 	'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Users_Screen">Documentation on Network Users</a>' ) . '</p>' .
    30 	'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>'
    30 	'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support forums</a>' ) . '</p>'
    31 );
    31 );
    32 
    32 
    33 if ( isset( $_REQUEST['action'] ) && 'add-user' === $_REQUEST['action'] ) {
    33 if ( isset( $_REQUEST['action'] ) && 'add-user' === $_REQUEST['action'] ) {
    34 	check_admin_referer( 'add-user', '_wpnonce_add-user' );
    34 	check_admin_referer( 'add-user', '_wpnonce_add-user' );
    35 
    35 
    75 			exit;
    75 			exit;
    76 		}
    76 		}
    77 	}
    77 	}
    78 }
    78 }
    79 
    79 
       
    80 $message = '';
    80 if ( isset( $_GET['update'] ) ) {
    81 if ( isset( $_GET['update'] ) ) {
    81 	$messages = array();
       
    82 	if ( 'added' === $_GET['update'] ) {
    82 	if ( 'added' === $_GET['update'] ) {
    83 		$edit_link = '';
    83 		$edit_link = '';
    84 		if ( isset( $_GET['user_id'] ) ) {
    84 		if ( isset( $_GET['user_id'] ) ) {
    85 			$user_id_new = absint( $_GET['user_id'] );
    85 			$user_id_new = absint( $_GET['user_id'] );
    86 			if ( $user_id_new ) {
    86 			if ( $user_id_new ) {
    91 		$message = __( 'User added.' );
    91 		$message = __( 'User added.' );
    92 
    92 
    93 		if ( $edit_link ) {
    93 		if ( $edit_link ) {
    94 			$message .= sprintf( ' <a href="%s">%s</a>', $edit_link, __( 'Edit user' ) );
    94 			$message .= sprintf( ' <a href="%s">%s</a>', $edit_link, __( 'Edit user' ) );
    95 		}
    95 		}
    96 
       
    97 		$messages[] = $message;
       
    98 	}
    96 	}
    99 }
    97 }
   100 
    98 
   101 // Used in the HTML title tag.
    99 // Used in the HTML title tag.
   102 $title       = __( 'Add New User' );
   100 $title       = __( 'Add New User' );
   103 $parent_file = 'users.php';
   101 $parent_file = 'users.php';
   104 
   102 
   105 require_once ABSPATH . 'wp-admin/admin-header.php'; ?>
   103 require_once ABSPATH . 'wp-admin/admin-header.php';
       
   104 ?>
   106 
   105 
   107 <div class="wrap">
   106 <div class="wrap">
   108 <h1 id="add-new-user"><?php _e( 'Add New User' ); ?></h1>
   107 <h1 id="add-new-user"><?php _e( 'Add New User' ); ?></h1>
   109 <?php
   108 <?php
   110 if ( ! empty( $messages ) ) {
   109 if ( '' !== $message ) {
   111 	foreach ( $messages as $msg ) {
   110 	wp_admin_notice(
   112 		echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
   111 		$message,
   113 	}
   112 		array(
       
   113 			'type'        => 'success',
       
   114 			'dismissible' => true,
       
   115 			'id'          => 'message',
       
   116 		)
       
   117 	);
   114 }
   118 }
   115 
   119 
   116 if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) {
   120 if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) {
   117 	?>
   121 	$error_messages = '';
   118 	<div class="error">
   122 	foreach ( $add_user_errors->get_error_messages() as $error ) {
   119 		<?php
   123 		$error_messages .= "<p>$error</p>";
   120 		foreach ( $add_user_errors->get_error_messages() as $message ) {
   124 	}
   121 			echo "<p>$message</p>";
   125 
   122 		}
   126 	wp_admin_notice(
   123 		?>
   127 		$error_messages,
   124 	</div>
   128 		array(
   125 <?php } ?>
   129 			'type'           => 'error',
       
   130 			'dismissible'    => true,
       
   131 			'id'             => 'message',
       
   132 			'paragraph_wrap' => false,
       
   133 		)
       
   134 	);
       
   135 }
       
   136 ?>
   126 	<form action="<?php echo esc_url( network_admin_url( 'user-new.php?action=add-user' ) ); ?>" id="adduser" method="post" novalidate="novalidate">
   137 	<form action="<?php echo esc_url( network_admin_url( 'user-new.php?action=add-user' ) ); ?>" id="adduser" method="post" novalidate="novalidate">
   127 	<table class="form-table" role="presentation">
   138 		<p><?php echo wp_required_field_message(); ?></p>
   128 		<tr class="form-field form-required">
   139 		<table class="form-table" role="presentation">
   129 			<th scope="row"><label for="username"><?php _e( 'Username' ); ?></label></th>
   140 			<tr class="form-field form-required">
   130 			<td><input type="text" class="regular-text" name="user[username]" id="username" autocapitalize="none" autocorrect="off" maxlength="60" /></td>
   141 				<th scope="row"><label for="username"><?php _e( 'Username' ); ?> <?php echo wp_required_field_indicator(); ?></label></th>
   131 		</tr>
   142 				<td><input type="text" class="regular-text" name="user[username]" id="username" autocapitalize="none" autocorrect="off" maxlength="60" required="required" /></td>
   132 		<tr class="form-field form-required">
   143 			</tr>
   133 			<th scope="row"><label for="email"><?php _e( 'Email' ); ?></label></th>
   144 			<tr class="form-field form-required">
   134 			<td><input type="email" class="regular-text" name="user[email]" id="email" /></td>
   145 				<th scope="row"><label for="email"><?php _e( 'Email' ); ?> <?php echo wp_required_field_indicator(); ?></label></th>
   135 		</tr>
   146 				<td><input type="email" class="regular-text" name="user[email]" id="email" required="required" /></td>
   136 		<tr class="form-field">
   147 			</tr>
   137 			<td colspan="2" class="td-full"><?php _e( 'A password reset link will be sent to the user via email.' ); ?></td>
   148 			<tr class="form-field">
   138 		</tr>
   149 				<td colspan="2" class="td-full"><?php _e( 'A password reset link will be sent to the user via email.' ); ?></td>
   139 	</table>
   150 			</tr>
       
   151 		</table>
   140 	<?php
   152 	<?php
   141 	/**
   153 	/**
   142 	 * Fires at the end of the new user form in network admin.
   154 	 * Fires at the end of the new user form in network admin.
   143 	 *
   155 	 *
   144 	 * @since 4.5.0
   156 	 * @since 4.5.0