| 1706 | /** |
| 1707 | * Retrieve user |
| 1708 | * |
| 1709 | * @uses get_userdata() |
| 1710 | * @param array $args Method parameters. Contains: |
| 1711 | * - int $blog_id |
| 1712 | * - string $username |
| 1713 | * - string $password |
| 1714 | * - int $user_id |
| 1715 | * @return array contains: |
| 1716 | * - 'user_login' |
| 1717 | * - 'user_firstname' |
| 1718 | * - 'user_lastname' |
| 1719 | * - 'user_registered' |
| 1720 | * - 'user_description' |
| 1721 | * - 'user_email' |
| 1722 | * - 'nickname' |
| 1723 | * - 'user_nicename' |
| 1724 | * - 'user_url' |
| 1725 | * - 'display_name' |
| 1726 | * - 'usercontacts' |
| 1727 | */ |
| 1728 | function wp_getUser( $args ) { |
| 1729 | |
| 1730 | $this->escape( $args ); |
| 1731 | |
| 1732 | $blog_ID = (int) $args[0]; |
| 1733 | $username = $args[1]; |
| 1734 | $password = $args[2]; |
| 1735 | $user_ID = (int) $args[3]; |
| 1736 | |
| 1737 | if ( !$user = $this->login( $username, $password ) ) |
| 1738 | return $this->error; |
| 1739 | |
| 1740 | $user_data = get_userdata( $user_ID ); |
| 1741 | |
| 1742 | if( ! $user_data ) |
| 1743 | return new IXR_Error(404, __('Invalid user ID')); |
| 1744 | |
| 1745 | if( ! ( $user_ID == $user->ID || current_user_can( 'edit_users' ) )) |
| 1746 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
| 1747 | |
| 1748 | $user_data = (array)$user_data; |
| 1749 | |
| 1750 | $contact_methods = _wp_get_user_contactmethods(); |
| 1751 | foreach( $contact_methods as $key => $value ) { |
| 1752 | $user_contacts[ $key ] = $user_data[ $key ]; |
| 1753 | } |
| 1754 | |
| 1755 | $struct = array( |
| 1756 | 'user_login' => $user_data['user_login'], |
| 1757 | 'user_firstname' => $user_data['user_firstname'], |
| 1758 | 'user_lastname' => $user_data['user_lastname'], |
| 1759 | 'user_registered' => $user_data['user_registered'], |
| 1760 | 'user_description' => $user_data['user_description'], |
| 1761 | 'user_email' => $user_data['user_email'], |
| 1762 | 'nickname' => $user_data['nickname'], |
| 1763 | 'user_nicename' => $user_data['user_nicename'], |
| 1764 | 'user_url' => $user_data['user_url'], |
| 1765 | 'display_name' => $user_data['display_name'], |
| 1766 | 'wp_capabilities' => $user_data['wp_capabilities'], |
| 1767 | 'wp_user_level' => $user_data['wp_user_level'], |
| 1768 | 'usercontacts' => $user_contacts, |
| 1769 | ); |
| 1770 | |
| 1771 | return $struct; |
| 1772 | |
| 1773 | } |
| 1774 | |