Skip to content

Commit

Permalink
Updated wp.deleteUser to latest Trac patch.
Browse files Browse the repository at this point in the history
Adds support for reassigned the to-be-deleted user's posts to another user.
  • Loading branch information
maxcutler committed Jan 21, 2012
1 parent 3fc7769 commit 2e0c547
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion class-wp-xmlrpc-server-ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,18 @@ function wp_deleteUser( $args ) {
if ( $user->ID == $user_id )
return new IXR_Error( 401, __( 'You cannot delete yourself.' ) );

return wp_delete_user( $user_id );
$reassign_id = 'novalue';
if ( isset( $args[4] ) ) {
$reassign_id = (int) $args[4];

if ( ! get_userdata( $reassign_id ) )
return new IXR_Error( 404, __('Invalid reassign user ID.' ) );

if ( $reassign_id === $user_id )
return new IXR_Error( 401, __( 'You cannot reassign to the user being deleted.' ) );
}

return wp_delete_user( $user_id, $reassign_id );
}

/**
Expand Down

0 comments on commit 2e0c547

Please sign in to comment.