WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wp_xmlrpc_server::login() WP 2.8.0

Log user in.

Это метод класса: wp_xmlrpc_server

Возвращает

WP_User/true/false. WP_User object if authentication passed, false otherwise

Использование

$wp_xmlrpc_server = new wp_xmlrpc_server();
$var = $wp_xmlrpc_server->login( $username, $password );
$username(строка) (обязательный)
User's username.
$password(строка) (обязательный)
User's password.

Список изменений

С версии 2.8.0 Введена.

Код wp xmlrpc server::login: wp-includes/class-wp-xmlrpc-server.php WP 5.2.3

<?php
public function login( $username, $password ) {
	/*
	 * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc'
	 * option was deprecated in 3.5.0. Use the 'xmlrpc_enabled' hook instead.
	 */
	$enabled = apply_filters( 'pre_option_enable_xmlrpc', false );
	if ( false === $enabled ) {
		$enabled = apply_filters( 'option_enable_xmlrpc', true );
	}

	/**
	 * Filters whether XML-RPC methods requiring authentication are enabled.
	 *
	 * Contrary to the way it's named, this filter does not control whether XML-RPC is *fully*
	 * enabled, rather, it only controls whether XML-RPC methods requiring authentication - such
	 * as for publishing purposes - are enabled.
	 *
	 * Further, the filter does not control whether pingbacks or other custom endpoints that don't
	 * require authentication are enabled. This behavior is expected, and due to how parity was matched
	 * with the `enable_xmlrpc` UI option the filter replaced when it was introduced in 3.5.
	 *
	 * To disable XML-RPC methods that require authentication, use:
	 *
	 *     add_filter( 'xmlrpc_enabled', '__return_false' );
	 *
	 * For more granular control over all XML-RPC methods and requests, see the {@see 'xmlrpc_methods'}
	 * and {@see 'xmlrpc_element_limit'} hooks.
	 *
	 * @since 3.5.0
	 *
	 * @param bool $enabled Whether XML-RPC is enabled. Default true.
	 */
	$enabled = apply_filters( 'xmlrpc_enabled', $enabled );

	if ( ! $enabled ) {
		$this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) );
		return false;
	}

	if ( $this->auth_failed ) {
		$user = new WP_Error( 'login_prevented' );
	} else {
		$user = wp_authenticate( $username, $password );
	}

	if ( is_wp_error( $user ) ) {
		$this->error = new IXR_Error( 403, __( 'Incorrect username or password.' ) );

		// Flag that authentication has failed once on this wp_xmlrpc_server instance
		$this->auth_failed = true;

		/**
		 * Filters the XML-RPC user login error message.
		 *
		 * @since 3.5.0
		 *
		 * @param string  $error The XML-RPC error message.
		 * @param WP_User $user  WP_User object.
		 */
		$this->error = apply_filters( 'xmlrpc_login_error', $this->error, $user );
		return false;
	}

	wp_set_current_user( $user->ID );
	return $user;
}