钩子文档

xmlrpc_call

💡 云策文档标注

概述

xmlrpc_call 是一个 WordPress 动作钩子,在 XML-RPC 用户认证后、方法逻辑执行前触发。所有内置 XML-RPC 方法都使用此钩子,参数为方法名,如 wp.getUsersBlogs、wp.newPost 等。

关键要点

  • 触发时机:XML-RPC 用户认证通过后,具体方法逻辑开始前
  • 参数:$name(方法名,字符串)、$args(传递给方法的转义参数,数组或字符串)、$server(XML-RPC 服务器实例,wp_xmlrpc_server 对象)
  • 用途:允许开发者在 XML-RPC 方法执行前添加自定义逻辑,例如日志记录、权限检查或参数修改
  • 相关方法:文档列出了大量使用此钩子的内置 XML-RPC 方法,涵盖文章、分类、用户、评论等操作

代码示例

do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this );

注意事项

  • 此钩子自 WordPress 2.5.0 引入,5.7.0 版本增加了 $args 和 $server 参数
  • 使用时需确保不干扰核心 XML-RPC 功能,避免安全风险

📄 原文内容

Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.

Description

All built-in XML-RPC methods use the action xmlrpc_call, with a parameter equal to the method’s name, e.g., wp.getUsersBlogs, wp.newPost, etc.

Parameters

$namestring
The method name.
$argsarray|string
The escaped arguments passed to the method.
$serverwp_xmlrpc_server
The XML-RPC server instance.

Source

do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this );

Changelog

Version Description
5.7.0 Added the $args and $server parameters.
2.5.0 Introduced.