Make WordPress Core

Ticket #14435: 14435.15.diff

File 14435.15.diff, 7.3 KB (added by PeteMall, 14 years ago)
  • wp-admin/network/edit.php

     
    444444                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
    445445        break;
    446446
    447         case 'adduser':
    448                 check_admin_referer( 'add-user', '_wpnonce_add-user' );
    449                 if ( ! current_user_can( 'manage_network_users' ) )
    450                         wp_die( __( 'You do not have permission to access this page.' ) );
    451 
    452                 if ( is_array( $_POST['user'] ) == false )
    453                         wp_die( __( 'Cannot create an empty user.' ) );
    454                 $user = $_POST['user'];
    455                 if ( empty($user['username']) && empty($user['email']) )
    456                         wp_die( __( 'Missing username and email.' ) );
    457                 elseif ( empty($user['username']) )
    458                         wp_die( __( 'Missing username.' ) );
    459                 elseif ( empty($user['email']) )
    460                         wp_die( __( 'Missing email.' ) );
    461 
    462                 $password = wp_generate_password();
    463                 $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
    464 
    465                 if ( false == $user_id )
    466                         wp_die( __( 'Duplicated username or email address.' ) );
    467                 else
    468                         wp_new_user_notification( $user_id, $password );
    469 
    470                 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) );
    471                 exit();
    472         break;
    473 
    474447        default:
    475448                wp_redirect( network_admin_url( 'index.php' ) );
    476449        break;
  • wp-admin/network/menu.php

     
    1414
    1515/* translators: Sites menu item */
    1616$menu[5] = array(__('Sites'), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'div');
    17 
    1817$submenu['sites.php'][5]  = array( __('Sites'), 'manage_sites', 'sites.php' );
    1918$submenu['sites.php'][10]  = array( __('Add New'), 'create_sites', 'site-new.php' );
    2019
    2120$menu[10] = array(__('Users'), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div');
     21$submenu['users.php'][5]  = array( __('Users'), 'manage_network_users', 'users.php' );
     22$submenu['users.php'][10]  = array( __('Add New'), 'manage_network_users', 'user-new.php' );
    2223
    2324$menu[15] = array(__('Themes'), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div');
    2425$submenu['themes.php'][5]  = array( __('Themes'), 'manage_network_themes', 'themes.php' );
  • wp-admin/network/user-new.php

     
     1<?php
     2
     3/**
     4 * Add Site Administration Screen
     5 *
     6 * @package WordPress
     7 * @subpackage Administration
     8 * @since 3.1.0
     9 */
     10
     11/** Load WordPress Administration Bootstrap */
     12require_once('./admin.php');
     13
     14if ( ! is_multisite() )
     15        wp_die( __( 'Multisite support is not enabled.' ) );
     16
     17if ( ! current_user_can('manage_network_users') )
     18        wp_die(__('You do not have sufficient permissions to add users to this network.'));
     19
     20if ( isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action'] ) {
     21        check_admin_referer( 'add-user', '_wpnonce_add-user' );
     22        if ( ! current_user_can( 'manage_network_users' ) )
     23                wp_die( __( 'You do not have permission to access this page.' ) );
     24
     25        if ( is_array( $_POST['user'] ) == false )
     26                wp_die( __( 'Cannot create an empty user.' ) );
     27        $user = $_POST['user'];
     28        if ( empty($user['username']) && empty($user['email']) )
     29                wp_die( __( 'Missing username and email.' ) );
     30        elseif ( empty($user['username']) )
     31                wp_die( __( 'Missing username.' ) );
     32        elseif ( empty($user['email']) )
     33                wp_die( __( 'Missing email.' ) );
     34
     35        $password = wp_generate_password();
     36        $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
     37
     38        if ( false == $user_id )
     39                wp_die( __( 'Duplicated username or email address.' ) );
     40        else
     41                wp_new_user_notification( $user_id, $password );
     42               
     43        wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) );
     44        exit;
     45}
     46
     47if ( isset($_GET['update']) ) {
     48        $messages = array();
     49        if ( 'added' == $_GET['update'] )
     50                $messages[] = __('User added.');
     51}
     52
     53$title = __('Add New User');
     54$parent_file = 'users.php';
     55
     56require('../admin-header.php'); ?>
     57
     58<div class="wrap">
     59<?php screen_icon(); ?>
     60<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
     61<?php
     62if ( ! empty( $messages ) ) {
     63        foreach ( $messages as $msg )
     64                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
     65} ?>
     66        <form action="<?php echo network_admin_url('user-new.php?action=add-user'); ?>" method="post"> 
     67        <table class="form-table">
     68                <tr class="form-field form-required">
     69                        <th scope="row"><?php _e( 'Username' ) ?></th>
     70                        <td><input type="text" class="regular-text" name="user[username]" /></td>
     71                </tr>
     72                <tr class="form-field form-required">
     73                        <th scope="row"><?php _e( 'Email' ) ?></th>
     74                        <td><input type="text" class="regular-text" name="user[email]" /></td>
     75                </tr>
     76                <tr class="form-field">
     77                        <td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
     78                </tr>
     79        </table>
     80        <p class="submit">
     81                <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
     82                <?php submit_button( __('Add User'), 'primary', 'add-user' ); ?>
     83        </form>
     84</div>
     85<?php
     86require('../admin-footer.php');
     87?>
     88 No newline at end of file
  • wp-admin/network/users.php

     
    6262        ?>
    6363<div class="wrap">
    6464        <?php screen_icon(); ?>
    65         <h2><?php esc_html_e( 'Users' ); ?>
    66         <a href="#form-add-user" class="button add-new-h2"><?php echo esc_html_x( 'Add New' , 'users'); ?></a>
    67         <?php
     65        <h2><?php esc_html_e( 'Users' );
     66        if ( current_user_can( 'create_users') ) : ?>
     67                <a href="<?php echo network_admin_url('user-new.php'); ?>" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'users' ); ?></a><?php
     68        endif;
     69       
    6870        if ( !empty( $usersearch ) )
    6971        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
    7072        ?>
     
    8284        </form>
    8385</div>
    8486
    85 <?php
    86 if ( apply_filters( 'show_adduser_fields', true ) ) :
    87 ?>
    88 <div class="wrap" id="form-add-user">
    89         <h3><?php _e( 'Add User' ) ?></h3>
    90         <form action="edit.php?action=adduser" method="post">
    91         <table class="form-table">
    92                 <tr class="form-field form-required">
    93                         <th scope="row"><?php _e( 'Username' ) ?></th>
    94                         <td><input type="text" class="regular-text" name="user[username]" /></td>
    95                 </tr>
    96                 <tr class="form-field form-required">
    97                         <th scope="row"><?php _e( 'Email' ) ?></th>
    98                         <td><input type="text" class="regular-text" name="user[email]" /></td>
    99                 </tr>
    100                 <tr class="form-field">
    101                         <td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
    102                 </tr>
    103         </table>
    104         <p class="submit">
    105                 <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
    106                 <input class="button" type="submit" value="<?php esc_attr_e( 'Add user' ) ?>" /></p>
    107         </form>
    108 </div>
    109 <?php endif;
    110 
    111 require_once( '../admin-footer.php' ); ?>
     87<?php require_once( '../admin-footer.php' ); ?>
     88 No newline at end of file