On this page
wp_xmlrpc_server::wp_getProfile( array $args ): array|IXR_Error
Retrieve information about the requesting user.
Parameters
$argsarray Required-
Method arguments. Note: arguments must be ordered as documented.
- int
Blog ID (unused).
1stringUsername2stringPassword3arrayOptional. Fields to return.
- int
Return
array|IXR_Error (@see wp_getUser)
Source
File: wp-includes/class-wp-xmlrpc-server.php. View all references
public function wp_getProfile( $args ) {
if ( ! $this->minimum_args( $args, 3 ) ) {
return $this->error;
}
$this->escape( $args );
$username = $args[1];
$password = $args[2];
if ( isset( $args[3] ) ) {
$fields = $args[3];
} else {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' );
}
$user = $this->login( $username, $password );
if ( ! $user ) {
return $this->error;
}
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this );
if ( ! current_user_can( 'edit_user', $user->ID ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
}
$user_data = get_userdata( $user->ID );
return $this->_prepare_user( $user_data, $fields );
}
Hooks
- do_action( 'xmlrpc_call',
string $name ,array|string $args ,wp_xmlrpc_server $server ) -
Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.
- apply_filters( 'xmlrpc_default_user_fields',
array $fields ,string $method ) -
Filters the default user query fields used by the given XML-RPC method.
Related
Uses
| Uses | Description |
|---|---|
| wp_xmlrpc_server::_prepare_user() wp-includes/class-wp-xmlrpc-server.php | Prepares user data for return in an XML-RPC object. |
| wp_xmlrpc_server::minimum_args() wp-includes/class-wp-xmlrpc-server.php | Checks if the method received at least the minimum number of arguments. |
| IXR_Error::__construct() wp-includes/IXR/class-IXR-error.php | PHP5 constructor. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| get_userdata() wp-includes/pluggable.php | Retrieves user info by user ID. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
| wp_xmlrpc_server::escape() wp-includes/class-wp-xmlrpc-server.php | Escape string or array of strings for database. |
| wp_xmlrpc_server::login() wp-includes/class-wp-xmlrpc-server.php | Log user in. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_getprofile