WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/24/2016 09:42:02 PM (6 years ago)
Author:
jeremyfelt
Message:

Multisite: Provide an "Edit user" link after adding a new user

Props codex-m, jeremyfelt.
Fixes #35705.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/user-new.php

    r36556 r36695  
    6060              */
    6161            do_action( 'network_user_new_created_user', $user_id );
    62             wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) );
     62            wp_redirect( add_query_arg( array('update' => 'added', 'user_id' => $user_id ), 'user-new.php' ) );
    6363            exit;
    6464        }
     
    6868if ( isset($_GET['update']) ) {
    6969    $messages = array();
    70     if ( 'added' == $_GET['update'] )
    71         $messages[] = __('User added.');
     70    if ( 'added' == $_GET['update'] ) {
     71        $edit_link = '';
     72        if ( isset( $_GET['user_id'] ) ) {
     73            $user_id_new = absint( $_GET['user_id'] );
     74            if ( $user_id_new ) {
     75                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) );
     76            }
     77        }
     78
     79        if ( empty( $edit_link ) ) {
     80            $messages[] = __( 'User added.' );
     81        } else {
     82            $messages[] = sprintf( __( 'User added. <a href="%1$s">Edit User</a>' ), $edit_link );
     83        }
     84    }
    7285}
    7386
Note: See TracChangeset for help on using the changeset viewer.