WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/02/2006 12:31:26 AM (12 years ago)
Author:
ryan
Message:

AJAXify user addition. Props mdawaffe. fixes #2624

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r3660 r3677  
    210210    die($r);
    211211    break;
     212case 'add-user' :
     213    if ( !current_user_can('edit_users') )
     214        die('-1');
     215    require_once( ABSPATH . WPINC . '/registration-functions.php');
     216    $user_id = add_user();
     217    if ( is_wp_error( $user_id ) ) {
     218        foreach( $user_id->get_error_codes() as $code)
     219                        foreach( $user_id->get_error_messages($code) as $message )
     220                                 echo "$message<br />";
     221    exit;
     222    } elseif ( !$user_id ) {
     223        die('0');
     224    }
     225    $r  = "<?xml version='1.0' standalone='yes'?><ajaxresponse><user><id>$user_id</id><newitem><![CDATA[<table><tbody>";
     226    $r .= user_row( $user_id );
     227    $r .= "</tbody></table>]]></newitem></user></ajaxresponse>";
     228    header('Content-type: text/xml');
     229    die($r);
     230    break;
    212231default :
    213232    die('0');
Note: See TracChangeset for help on using the changeset viewer.