| | 1706 | /** |
| | 1707 | * Delete a user |
| | 1708 | * |
| | 1709 | * @uses wp_delete_user() |
| | 1710 | * @param array $args Method parameters. Contains: |
| | 1711 | * - int $blog_id |
| | 1712 | * - string $username |
| | 1713 | * - string $password |
| | 1714 | * - int $user_id |
| | 1715 | * @return True when user is deleted. |
| | 1716 | */ |
| | 1717 | function wp_deleteUser( $args ) { |
| | 1718 | $this->escape( $args ); |
| | 1719 | |
| | 1720 | $blog_id = (int) $args[0]; |
| | 1721 | $username = $args[1]; |
| | 1722 | $password = $args[2]; |
| | 1723 | $user_id = (int) $args[3]; |
| | 1724 | |
| | 1725 | if( ! $user = $this->login( $username, $password ) ) |
| | 1726 | return $this->error; |
| | 1727 | |
| | 1728 | do_action( 'xmlrpc_call', 'wp.deleteUser' ); |
| | 1729 | |
| | 1730 | if( ! current_user_can( 'delete_users' ) ) |
| | 1731 | return new IXR_Error( 401, __( 'You are not allowed to delete users.' ) ); |
| | 1732 | |
| | 1733 | if( ! get_userdata( $user_id ) ) |
| | 1734 | return new IXR_Error( 404, __('Invalid user ID.' ) ); |
| | 1735 | |
| | 1736 | if( $user->ID == $user_id ) |
| | 1737 | return new IXR_Error( 401, __( 'You cannot delete yourself.' ) ); |
| | 1738 | |
| | 1739 | return wp_delete_user( $user_id ); |
| | 1740 | } |
| | 1741 | |