You are here

function hook_xmlrpc_alter in Drupal 7

Alters the definition of XML-RPC methods before they are called.

This hook allows modules to modify the callback definition of declared XML-RPC methods, right before they are invoked by a client. Methods may be added, or existing methods may be altered.

Note that hook_xmlrpc() supports two distinct and incompatible formats to define a callback, so care must be taken when altering other methods.

Parameters

$methods: An asssociative array of method callback definitions, as returned from hook_xmlrpc() implementations.

See also

hook_xmlrpc()

xmlrpc_server()

Related topics

1 function implements hook_xmlrpc_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

xmlrpc_test_xmlrpc_alter in modules/simpletest/tests/xmlrpc_test.module
Implements hook_xmlrpc_alter().
1 invocation of hook_xmlrpc_alter()
xmlrpc_server in includes/xmlrpcs.inc
Invokes XML-RPC methods on this server.

File

modules/system/system.api.php, line 2468
Hooks provided by Drupal core and the System module.

Code

function hook_xmlrpc_alter(&$methods) {

  // Directly change a simple method.
  $methods['drupal.login'] = 'mymodule_login';

  // Alter complex definitions.
  foreach ($methods as $key => &$method) {

    // Skip simple method definitions.
    if (!is_int($key)) {
      continue;
    }

    // Perform the wanted manipulation.
    if ($method[0] == 'drupal.site.ping') {
      $method[1] = 'mymodule_directory_ping';
    }
  }
}