钩子文档

clear_auth_cookie

💡 云策文档标注

概述

clear_auth_cookie 是一个 WordPress 动作钩子,在清除认证 cookies 之前触发。它允许开发者在用户登出或认证状态变化时执行自定义代码。

关键要点

  • clear_auth_cookie 是一个 do_action 钩子,在 wp_clear_auth_cookie() 函数中调用。
  • 它用于在清除认证 cookies 前执行操作,例如清理用户会话数据或记录日志。
  • 该钩子自 WordPress 2.7.0 版本引入,位于 wp-includes/pluggable.php 文件中。

代码示例

add_action( 'clear_auth_cookie', 'my_custom_clear_auth_cookie_action' );
function my_custom_clear_auth_cookie_action() {
    // 在清除认证 cookies 前执行自定义代码
    error_log( 'Authentication cookies are about to be cleared.' );
}

📄 原文内容

Fires just before the authentication cookies are cleared.

Source

do_action( 'clear_auth_cookie' );

Changelog

Version Description
2.7.0 Introduced.